Running 2 services

I’m building an image for github’s Linkurious project, based on an image already in the hub for the neo4j database. the neo image automatically runs the server on port 7474 and my image runs on port 8000.

when I run my image I publish both ports (could I do this with EXPOSE?):

  • Restore deleted container docker
  • how can I create a data-container only using docker-compose.yml?
  • Can not connect to Kafka with port 9092
  • nginx docker instance multiple application
  • Couldn't connect to Docker daemon on Mac OS X
  • Docker service does not start
  • docker run -d --publish=7474:7474 --publish=8000:8000 linkurious
    

    but only my server seems to run. if I hit http://[ip]:7474/ I get nothing. is there something special I have to do to make sure they both run?

    * Edit I *

    here’s my Dockerfile:

    FROM neo4j/neo4j:latest
    RUN apt-get -y update
    RUN apt-get install -y git
    RUN apt-get install -y npm
    RUN apt-get install -y nodejs-legacy
    RUN git clone git://github.com/Linkurious/linkurious.js.git
    RUN cd linkurious.js && npm install && npm run build
    CMD cd linkurious.js && npm start
    

    * Edit II *

    to perhaps help explain my quandary, I’ve asked a different question

  • Issues accessing Sinatra app in Docker container
  • Run Jenkins master and slave with Docker
  • Chain automated builds in the same Docker Hub repository
  • Dealing with “HTTP request timed out. Exiting.” when building a large aspnet project for Docker
  • Mongodb docker container with client access control
  • Jenkins shell script add Unix user to group
  • One Solution collect form web for “Running 2 services”

    EXPOSE is there to allow inter-containers communication (within the same docker daemon), with the docker run --link option.
    Port mapping is there to map EXPOSEd ports to the host, to allow client-to-container communication. So you need --publish.

    See also “Difference between “expose” and “publish” in docker”.

    See also an example with “Advanced Usecase with Docker: Connecting Containers”

    http://codentrick.com/home/wp-content/uploads/2015/07/Docker_Linking_Dual-640x480.jpg


    Make sure though that the ip is the right one ($(docker-machine ip default)).


    If you are using a VM (meaning, you are not using docker directly on a Linux host, but on a Linux VM with VirtualBox), make sure the mapped ports 7474 and 8000 are port forwarded from the host to the VM.

    VBoxManage controlvm boot2docker-vm natpf1 "name,tcp,,7474,,7474"
    VBoxManage controlvm boot2docker-vm natpf1 "name,tcp,,8000,,8000"
    

    In the OP’s case, this is using neo4j: see “Neo4j with Docker”, based on the neo4j/neo4j/ image and its Dockerfile:

    ENTRYPOINT ["/docker-entrypoint.sh"] 
    CMD ["neo4j"]
    

    It is not meant to be used for installing another service (like nodejs), where the CMD cd linkurious.js && npm start would completely override the neo4j base image CMD (meaning neo4j would never start).

    It is meant to be run on its own:

    # interactive with terminal
    docker run -i -t --rm --name neo4j -v $HOME/neo4j-data:/data -p 8474:7474 neo4j/neo4j
    
    # as daemon running in the background
    docker run -d --name neo4j -v $HOME/neo4j-data:/data -p 8474:7474 neo4j/neo4j
    

    And then used by another image, with a --link neo4j:neo4j directive.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.