docker personal study notes

docker commonly used commands

Restart docker

systemctl restart docker

Mirror operations

  • View Mirror
docker images
  • Remove Mirror
docker rmi “镜像ID”
  • Mirror intermediate layer
docker images -a
  • View Status
docker system df

Operation container

  • Check the operation of the vessel
docker ps
  • View all containers
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
  • Delete all containers
docker rm $(docker ps -a -q)
  • Stop all containers
docker stop $(docker ps -a -q)
  • Stop the container
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

  • Create a data volume
vi dockerfile
  • Write Dockerfile
    1. Data volume name must be: Dockerfile (otherwise it will error when building Mirror)

d

FROM  "要继承的镜像"
COPY “要传输的文件” “传入到镜像中的位置”
  • Construction of Mirror
  1. docker build: Construction mirroring
  2. The following commands. "" Current directory, based on the means to build the mirror current directory dockerfile
  3. From the name of their own mirror can not have capital letters
  4. 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
Published 13 original articles · won praise 8 · views 1305

Guess you like

Origin blog.csdn.net/yaoliyuan0922/article/details/102692117