docker commonly used commands
Restart docker
systemctl restart docker
Mirror operations
docker images
docker rmi “镜像ID”
- Mirror intermediate layer
docker images -a
docker system df
Operation container
- Check the operation of the vessel
docker ps
docker ps -a
- New Container here for an example tomcat (-p host port: container port) (- name "Alias") (- d: running in the background)
docker run -p 8080:8080 --name mytomcat -d tomcat
docker rm $(docker ps -a -q)
docker stop $(docker ps -a -q)
docker stop “容器ID”
- Start the original container
docker start “容器ID”
- Delete container (not delete the container start-up state)
docker rm "容器ID"
- Forced to delete container
docker rm -f
- Interactive into the container (you can modify files)
docker exec -it "容器ID" /bin/bash
Create a data volume
vi dockerfile
- Write Dockerfile
1. Data volume name must be: Dockerfile (otherwise it will error when building Mirror)
FROM "要继承的镜像"
COPY “要传输的文件” “传入到镜像中的位置”
- docker build: Construction mirroring
- The following commands. "" Current directory, based on the means to build the mirror current directory dockerfile
- From the name of their own mirror can not have capital letters
- When building image, in fact, the package file in the current directory to the directory mirrored build
docker build -t "自己起的镜像名字" .
- DockerFile instruction
- FROM: inherit a mirror
- RUN: Run command
- COPY: Copy the file to a specified directory
- ADD: COPY with similar, but more than COPY senior, is not recommended. (Comes with decompression)
- CMD: used to enter a shell script (can only be used once)
- ENTRYPOINT: CMD upgraded version (only once)
- ENV: Environment Variables
- VOLUME: Volume Data
- EXPOSE: exposed ports
- WORKDIR: similar to "Cd" command specifies the initial command file
MySql container starts:
- We need to configure port mapping and initial password
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag