When you run the attach command your terminal attaches to the nginx process.Īnd you can watch the output of the nginx process in real time. The default command of the nginx image which is executed when you run the container is set to CMD. To make sure the “my_nginx” container is running: docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESĨe1c4974a8d8 nginx "nginx -g 'daemon of…" 3 minutes ago Up 2 seconds 0.0.0.0:8080->80/tcp my_nginxĪttach to the container using the container’s ID or name: docker container attach my_nginx The -p 8080:80 option tells Docker to map port 80 in the container to port 8080 on the host machine. docker container run -name my_nginx -d -p 8080:80 nginx To better understand how the attach command works let’s runĪ new detached Nginx container using the official Nginx image. This is useful when you want to see what is written in the standard output in real-time, or to control the process interactively. The command that is executed when starting a container is specified using the ENTRYPOINT and/or RUN instruction.Īllows you to attach your terminal to the running container. Attach to a Container #Īlthough it is possible to run multiple processes in a container, most docker containers are running only a single process. In this tutorial, we will explain how to attach to the container’s main running process and how to get a shell to a running container. Discover the Best Web GUI for Docker: Easily Manage Your Containers with Portainer
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |