-1

I can start and exec into a ubuntu docker container using this command:

$ docker container run -it --rm ubuntu
root@ded56bdb6f95:/#

However, I get a blank console when I attempt to do the same for an nginx server (though it does print the logs here):

$ docker container run -it -p 81:80 --rm nginx
# this is blank

I can exec in by running an additional command while the nginx server is runnning:

docker container exec -it CONTAINER_ID bash
root@6270d301d3fd:/#

Any idea what I'm doing wrong or if this is the expected behavior?

Johnny Metz
  • 5,977
  • 18
  • 82
  • 146
  • Can you add output of: docker ps -a I think you have the wrong image name – Tarek Nov 23 '19 at 20:11
  • You should generally imagine a container as a wrapper around a single process. In the same way that it doesn't really make sense to get a shell in your Chrome/Firefox browser, it doesn't make sense to get a shell in an Nginx server either, and you should reserve interactive shells and `docker exec` for debugging and not day-to-day use. – David Maze Nov 24 '19 at 00:35

1 Answers1

0

Figured it out, just need to add the name of the shell (e.g. bash or sh) to the end of the docker run command:

docker container run -it -p 81:80 --rm nginx bash
Johnny Metz
  • 5,977
  • 18
  • 82
  • 146