Issue running container in interactive mode

I am running a docker container in amazon linux2. The container has a node/express web application which I access through my browser at port 443. When I run the container in attached mode or detached mode using a command similar to docker run -p443:443 -d node_express_aws, everything works and I am able to access it through my browser.

The issue is that if I run my container in interactive mode with a command such as docker run -p443:443 -it node_express_aws sh, I am able to use the sh terminal to run commands inside the container. However I can no longer access the running web application from my web browser.

I would really like to know why running using interactive mode could cause this issue.

Probably because there is no running application at all. You specified the command as the last argument to be “sh” overriding the original command that ran the application. If you want to work in the terminal, create the container without overriding the command and use docker exec to get a shell in the container

docker exec -it containername sh
1 Like