Skip to main content

Docker User Guide

Introduction​

Docker is an open-source platform designed to simplify the development, deployment, and running of applications. Docker uses container technology to achieve this goal. A container is a lightweight, standalone runtime environment.

Installing Docker​

sudo apt-get update
sudo apt-get install -y docker.io docker-buildx

Basic Commands​

Check Docker Version​

sudo docker --version

Pull an Image​

sudo docker pull <image_name>

Run a Container​

sudo docker run -it <image_name>

List Running Containers​

sudo docker ps

Stop a Container​

sudo docker stop <container_id>

Building an Image​

Create a Dockerfile​

# Dockerfile
FROM harbor.spacemit.com/bianbu/bianbu:2.3.3
RUN apt-get update && apt-get install -y python3
COPY . /app
WORKDIR /app
CMD ["python3", "app.py"]

harbor.spacemit.com/bianbu/bianbu:latest currently points to Bianbu 4.0 and uses RVA23 instructions, so it can only run on K3.

For K1, use a bianbu:2.x image explicitly, for example harbor.spacemit.com/bianbu/bianbu:2.3.3.

Detailed Dockerfile Syntax

Make sure to include a file named app.py in your project directory, which will be executed as the entry point when the container starts.

# app.py
def main():
print("Hello, Docker!")

if __name__ == "__main__":
main()

Build the Image​

sudo docker buildx build -t myapp --load -f Dockerfile .

Run​

sudo docker run --rm myapp

You should see the output Hello, Docker!

Managing Containers​

View All Containers​

docker ps -a

Remove a Container​

docker rm <container_id>

Remove an Image​

docker rmi <image_id>

Common Issues​

How to Clean Up Unused Images and Containers?​

docker system prune

How to View Container Logs?​

docker logs <container_id>

How to Enter a Running Container?​

docker exec -it <container_id> /bin/bash