Table of Contents
- 1 Introduction
- 2 Docker My Note: Your Go-To Guide for DevOps Success
- 2.1 Cannot connect to the Docker daemon. Is the docker daemon running on this host?
- 2.2 Detach and Attach
- 2.3 Why can not detach?
- 2.4 Docker runs without -it, but attach, so can not type CTRL-C
- 2.5 To safely detach…
- 2.6 You want to log in to a container…
- 2.7 start on os-startup
- 2.8 search a docker image in hub.docker.com
- 2.9 Download a docker image from hub.docker.com
- 2.10 List out docker images from your local system
- 2.11 Expose your application to host server
- 2.12 List out running containers
- 2.13 List out all docker containers (running, stpooed, terminated, etc…)
- 2.14 Stop/Start a container
- 2.15 Remove a container
- 3 Conclusion
Introduction
Docker is a popular tool in the DevOps field that simplifies the deployment and management of applications.
In this article, we will explore important notes about Docker, including basic concepts, common commands, and useful tips. Whether you are a beginner or have some experience, these notes will help you optimize your work with Docker. To learn more, visit Docker My Note.
Docker My Note: Your Go-To Guide for DevOps Success
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
Solve the problem: Add this user to the docker group.
Detach and Attach
- Detach : Ctrl-p + Ctrl-q
- Attach: docker attach [container]
Why can not detach?
Solve the problem: docker run with “-i”, “-t” options. http://stackoverflow.com/questions/20145717/how-to-detach-from-a-docker-container
Docker runs without -it, but attach, so can not type CTRL-C
Close your terminal! Anything OK.
To safely detach…
Docker runs without “-i”, “-t” options. But you want to detach, if you hit Ctrl-C then the docker process be killed.
To avoid it, attach with
--sig-proxy=false
You want to log in to a container…
docker exec -it [container-name] /bin/bash
start on os-startup
docker command
--restart=always
docker-compose add restart: always in docker-compose.yaml file
search a docker image in hub.docker.com
docker search nginx
Download a docker image from hub.docker.com
docker image pull <image_name>:<image_version/tag>
List out docker images from your local system
docker image ls
Expose your application to host server
docker run -d -p <host_port>:<container_port> --name <container_Name> <image_name>:<Image_version/tag>
List out running containers
docker ps
List out all docker containers (running, stpooed, terminated, etc…)
docker ps -a
Stop/Start a container
docker stop <container_id> docker start <container_id>
Remove a container
docker rm <container_id>
Conclusion
Docker has become an indispensable tool in the modern DevOps toolkit. Through this article, we hope you have grasped the basic knowledge and useful commands to effectively apply Docker in your work. If you want to learn more and stay updated with the latest information about Docker, don’t forget to visit Docker My Note. Let Docker help you simplify and optimize your application deployment process.