Introduction to docker practical commands

Source: Internet
Author: User
Tags docker stop container docker ps docker run
Introduction to docker practical commands

 

1. Start, close, and stop docker
╭─wil-xz in ~                                                                                                                                    12:15:44
╰─?(?﹏?、)?  service docker restart 
Redirecting to /bin/systemctl restart docker.service
╭─wil-xz in ~                                                                                                                                    12:15:44╰─?(?﹏?、)?  service docker stop 
Redirecting to /bin/systemctl stop docker.service
╭─wil-xz in ~                                                                                                                                    12:15:44╰─?(?﹏?、)?  service docker start 
Redirecting to /bin/systemctl start docker.service
2. view all current docker images. Docker Images
╭─wil-xz in ~                                                                                                                                    12:15:44╰─?(?﹏?、)?  docker imagesREPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZEwill3369/php5.6                                 latest              838e8980cb1d        2 days ago          506MB
3. Find the image of a service environment. Docker search PHP
╭─wil-xz in ~                                                                                                                                    12:16:31╰─(?? ??_??)?  docker search phpNAME                                                      DESCRIPTION                                     STARS               OFFICIAL            AUTOMATEDphp                                                       While designed for web development, the PHP …   3992                [OK]                phpmyadmin/phpmyadmin                                     A web interface for MySQL and MariaDB.          644                                     [OK]
4. Pull the image. Docker pull PHP
─ ── Wil-xz IN ~ 12:17:57 docker pull phpusing default tag: latestlatest: pulling from library/phpdigest: sha256: container: image is up to date for PHP: Latest
5. Run the container. Docker run-tid -- name container_name PHP
╭─wil-xz in ~                                                                                                                                    12:18:08╰─ε=ε=ヾ(;?д?)/  docker run -tid --name php_c php         c77ba90444b478444bcb7dc27205c7980bbe196b101fb08c3c404f2b813e156e
6. view the container. Docker ps or docker PS-a, docker PS to view the running container, and docker PS-a to view all containers, that is, the stopped container and the container that fails to start.
╭─wil-xz in ~                                                                                                                                    12:18:54╰─╰(*°▽°*)╯  docker psCONTAINER ID        IMAGE                                               COMMAND                  CREATED             STATUS              PORTS                              NAMESc77ba90444b4        php                                                 "docker-php-entrypoi…"   13 seconds ago      Up 20 seconds           
7. view the container error log. Docker logs container name. If the container is not started successfully, that is, after docker run finds that docker PS does not see the running container, you can run this command to view the error message.
╭─wil-xz in ~                                                                                                                                    12:20:30╰─(*′?д?)?  docker logs cdbmaster2018-10-31 08:38:20 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2018-10-31 08:38:20 0 [Note] mysqld (mysqld 5.6.41-log) starting as process 1 ...2018-10-31 08:38:20 1 [Note] Plugin ‘FEDERATED‘ is disabled.2018-10-31 08:38:20 1 [Note] InnoDB: Using atomics to ref count buffer pool pages2018-10-31 08:38:20 1 [Note] InnoDB: The InnoDB memory heap is disabled
8. view the container environment. Docker inspect container name

9. view the processes running in the container. Docker top container name
╭─wil-xz in ~                                                                                                                                    12:21:12╰─(?3?)~?  docker top php_cPID                 USER                TIME                COMMAND28858               root                0:00                php -a
10. view the container binding port. Docker port container name
─ ── Wil-xz IN ~ 12:22:57 mongo── O (container port) O docker port cmysqlproxy4040/TCP-> 0.0.0.0: 4040
11. Enter the container. Docker Exec-It container name bash
╭─wil-xz in ~                                                                                                                                    12:22:58╰─ヽ(*。>Д<)o゜  docker exec -it php_c bash[email protected]:/# 
12. Delete the container. Docker RM container name. Run the docker stop container name to stop the container before deleting the container.
╭─wil-xz in ~                                                                                                                                    12:23:53╰─ヾ(;?;Д;?;)??  docker stop php_cphp_c╭─wil-xz in ~                                                                                                                                    12:24:11╰─ヾ(;?;Д;?;)??  docker rm php_cphp_c
13. Delete all containers. Docker RM $ (docker PS-a-Q ). Before stopping all containers, run docker stop $ (docker PS-a-Q ).
╭─wil-xz in ~                                                                                                                                    12:24:22╰─?(?﹏?、)?  docker rm $(docker ps -a -q)
14. Delete the image. Docker RMI image name
╭─wil-xz in ~                                                                                                                                    12:25:33╰─(?3?)~?  docker rmi phpUntagged: php:latestUntagged: [email protected]:417dd4c0f12e5cd3f284b48b5ea6b13d38eda8eacc9008774637df389590d6daDeleted: sha256:df1b7c730f916447514631a9f9847fc39d6f55cc2525693700623939aa946b78

 

Introduction to docker practical commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.