docker command
docker images
Mirror list
docker ps
service list
docker hidden packed files
.dockerignore
.git
node_modules
npm-debug.log
Dockerfile
FROM node:10.16.0-alpine
WORKDIR /app
RUN npm install --registry=https://registry.npm.taobao.org
EXPOSE 80
ENTRYPOINT [ "npm", "run", "start" ]
Packaging current directory
docker image build -t node-app .
Generating vessel docker container run
docker container run -p 114:8080 -it --name containerName -v /www/wwwroot/node.test.com:/app -d --privileged=true --restart=always node-app
--privileged
Open root
privilege
--restart=always
automatically restart if you create is not used to update the container configuration command:docker container update --restart=always 容器名字
Directory Map
-v /Users/root/webProject/test/App:/app
The container list docker container ls
docker ls
停止 / 开始 指定的容器运行
docker start xxx
docker kill xxx
docker stop xxx
docker restart xxxx
docker logs
docker logs containerName -f 查看实时记录
docker exec
docker exec -it < name > sh
docker stop $(docker ps -a -q) 停止所有
docker rm $(docker ps -a -q) 删除所有
Container operations
docker export $container_id > 容器快照名 容器导出
cat centos.tar | docker import - my/centos:v888 容器导入
docker rm [container_id]
docker rm -f [container_id] 删除运行状态下 加 -f 参数
docker load 镜像载入
docker save 镜像载出
docker import
docker export
Mirroring Save / Load: docker load
/ docker save
; exported as an image file, and then use docker load command to import the file into a mirror, the mirror will save all of history. Than docker export command to export the file size, well understood, as it will save all the history of mirroring.
Container import / export: docker import
/ docker export
; a container export file, and then use docker import command will import container into a new image, but compared docker save command, you will lose all container file metadata and history, saved only when the container the state, the equivalent of a virtual machine snapshots.
Delete Mirror
docker rmi <image id>
想要删除untagged images,也就是那些id为<None>的image的话可以用
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
要删除全部image的话
docker rmi $(docker images -q)