Docker: Unable to specify port for a running container

I am a newbiew to Docker. I am using Mac hence have installed Docker in HortonWorks Sandbox Virtual Box.

I am trying to create 2 containers out of a Ubuntu base image. One container runs nodejs on it and other with mysql.

  • Ubuntu timedatectl fails in Docker container
  • How to create a docker base image?
  • Pass environment variable to docker
  • How do I add a container user to a user group in the Docker host?
  • interactive docker build from dockerfile?
  • How to deal with temporary apt-key adv failures?
  • I am able to create a container and it lists under Docker ps, but when I try to specify port for that container, it doesn’t show me any error, but the port is not getting set.

    Command used to add port to a running container:

    docker run -p 8080:8080 nodejsapp

    where node jsapp is my Image name of 1 container.

    Any help would be really appreciated. Thanks.

  • Access S3 in cron job in docker on Elastic Beanstalk
  • Docker container not exposed on network
  • Automatically run a script when HBase master Docker container finishes initializing
  • docker compose with build --pull option
  • user unbound variable on docker run
  • ERROR: Service 'redis' failed to build. When building redis image by docker-compose
  • One Solution collect form web for “Docker: Unable to specify port for a running container”

    It’s hard to say without seeing your Dockerfile and without knowing what error messages you’re seeing, but my guess is that you’re not telling NodeJS what port to run on. The convention in NodeJS is to do this with the NODE_PORT environment variable:

    docker run -e NODE_PORT=8080
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.