Featured image of post Docker 基本操作

Docker 基本操作

打包image

$ docker build -t user/testig:1.0 .
$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
user/testig       1.0                 1cbbafbff8fc        100 days ago          1MB

執行

$ docker run -d --network=host -e ID=1 user/testig:1.0
# -d  Run container in background and print container ID
# -e  Set environment variables

停止

$ docker stop <ID>

清單

$ docker ps -a -s

Log

$ docker logs -f <ID>

進入容器

$ docker exec -it <ID> bash

上傳

$ docker push user/testig:latest

下載

$ docker pull user/testig

volume

$ docker volume create --name <name>
$ docker volume ls

$ docker run -v <name>:/some/dist/path/ <container name/container ID>

or

$ docker run -v /some/host/path:/some/dist/path/ <image name/image ID>

 

Licensed under CC BY-NC-SA 4.0
Last updated on Oct 27, 2023 20:21 CST