1、在后台运行friendlyhello程序
docker run -d -p 4000:80 friendlyhello
2、查看容器
docker container ls
3、查看镜像
docker image ls
4、用docker ID来结束容器
docker container stop 1fa4ab2cf395
5、登录阿里云Docker Registry
$ sudo docker login --username=[用户名] registry.cn-xxxx.aliyuncs.com
6、从Registry中拉取镜像
$ sudo docker pull registry.cn-xxxx.aliyuncs.com/******:[镜像版本号]
其中registry.cn-xxxx.aliyuncs.com/******代表registry的公网地址,下同。
7、将镜像推送到Registry
$ sudo docker login --username=[用户名] registry.cn-xxxx.aliyuncs.com
$ sudo docker tag [ImageId] registry.cn-xxxx.aliyuncs.com/*****:[镜像版本号]
$ sudo docker push registry.cn-xxxx.aliyuncs.com/******:[镜像版本号]
8、命令摘要汇总
docker build -t friendlyhello . # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyhello # Run "friendlyname" 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