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?
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