$ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE friendlyhello latest 7ecc82fd960a 53 minutes ago 148MB python 2.7-slim 5f759d36aead 7 hours ago 137MB hello-world latest fce289e99eb9 7 months ago 1.84kB
$ docker run -d -p 4000:80 friendlyhello c21b81020e77e9f15df5fafbfdaf2791599c6233b4169615ea9226f243ff68b8
$ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c21b81020e77 friendlyhello "python app.py" About a minute ago Up About a minute 0.0.0.0:4000->80/tcp elegant_raman
# 关闭程序 $ docker container stop c21b
$ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
相关命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
docker build -t friendlyhello . # Create image using this directory's Dockerfile docker run -p 4000:80 friendlyhello # Run "friendlyhello" mapping port 4000 to 80 docker run -d -p 4000:80 friendlyhello # Same thing, but in detached mode docker container ls # List all running containers docker container ls -a # List all containers, even those not running docker container stop <hash> # Gracefully stop the specified container docker container kill <hash> # Force shutdown of the specified container docker container rm <hash> # Remove specified container from this machine docker container rm $(docker container ls -a -q) # Remove all containers docker image ls -a # List all images on this machine docker image rm <image id> # Remove specified image from this machine docker image rm $(docker image ls -a -q) # Remove all images from this machine docker login # Log in this CLI session using your Docker credentials docker tag <image> username/repository:tag # Tag <image> for upload to registry docker push username/repository:tag # Upload tagged image to registry docker run username/repository:tag # Run image from a registry