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

  • Deploying Java app to Docker image
  • How can I forward traffic from a specific port to another in open-vswitch
  • Docker: Run command while another command is running
  • Unable to connect to remote MySQL from a docker on Ubuntu Desktop
  • google app engine configure a specific image / snapshot / docker?
  • How to connect cassandra which is in a docker image from outside the OS
  • 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

  • Nodemon Doesn't Restart in Windows Docker Environment
  • Boot2Docker on Mac - Accessing Local Files
  • How to run a CMD and open Bash when running a docker container?
  • docker: “commit” requires a maximum of 2 arguments
  • CentOS7 Docker login/ pull x509: certificate signed by unknown authority
  • docker-compose run returns /bin/ls cannot execute binary file
  • 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.