Report this

What is the reason for this report?

After I run a docker run command it gets stuck indefinitely

Posted on February 1, 2022
vladoneBullet

By vladoneBullet

Net Core Full Stack

Hi! I have an ubuntu droplet setup. I run the command “docker run -p 8080:80 dockerhub_username/dockerhub_repo”. After this command the terminal gets stuck indefinitely, and i cannot perform any other actions unless i press ctrl + c. How may I make this work ?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello there,

You can add the -d flag in order to run the docker container in the background.

To run a docker container in the background or the detached mode from the terminal, you can use the docker run command followed by the -d flag (or detached flag) and followed by the name of the docker image you need to use in the terminal.

  1. docker run -d -p 8080:80 dockerhub_username/dockerhub_repo

Hope that this helps! Regards, Alex

Hello,

Indeed as Alex already mentioned, if you do not specify the -d flag the container will run in the foreground so that whenever you press CTRL+C or close your terminal the container will be terminated.

For more information on getting started with Docker, I could also suggest the following open-source ebook:

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.