The first day | Docker learning

Basic commands

Out of the container

Ctrl +P+ Q # does not stop exitCopy the code

Remove the container

Docker rm container ID # Said mandatory delete docker ps - a - q | xargs docker rm -f # mandatory delete all containers (ubuntu applicable) docker ps - f $# (docker ps - a - q) mandatory delete all containers (centos applicable)Copy the code

Common commands

Background startup container

Docker run -d name --name container name -p host port: internal port # -d indicates background executionCopy the code

See the log

Dockter logs -f -t --tail Container ID Dockter logs -f -t --tail Container IDCopy the code

View the process information in the container

Docker Top Container IDCopy the code

View the metadata of the mirror

Docker inspect Container IDCopy the code

Enter the currently running container

Docker exec -- it container id -- bashShell Docker attach # docker attach # docker attach #Copy the code

Using a Data Volume

Method 1: Run commands to mount the vm

Docker run -it -v host directory: # -v mountCopy the code

Practice: Install MySQL

Docker run - name - the name mysql container e MYSQL_ROOT_PASSWORD = password - d \ -p hosting port: container port \ -v hosting a directory/mysql/conf: / etc/mysql/conf. D \ - v Hosting a directory/mysql/data: / var/lib/mysql mysql: version # such as: docker run --name mysql01 -e MYSQL_ROOT_PASSWORD=root -d \ -p 3307:3306 \ -v /home/ulonglonggogo/mysql/conf:/etc/mysql/conf.d \ -v /home/ulonglonggogo/mysql/data:/var/lib/mysql mysqlCopy the code

This article uses the article synchronization assistant to synchronize