How to set up multiple docker containers for multiple developers on the same host?

I need to set up a developer window with Docker and that means I will have:

  • different containers working in the same environment
  • various developers referring to each of these containers

This is a setup that will run multiple containers on a "central server" and developers will connect to this "central server" via SSH or Samba or any other way (not yet defined).

Let's take this as a small example:

/home/dev1/sources
/home/dev2/sources

cont_dev1 (volumes) => /home/dev1/sources:/var/www/html | port: 8080 | URL: http://dev1.box.com
cont_dev2 (volumes) => /home/dev2/sources:/var/www/html | port: 8081 | URL: http://dev2.box.com

      

box.com

is the domain assigned to the external IP address on the "central server".

The idea is not to install development tools on the server itself, so we can take advantage of Docker (easily switch between tools just by mentioning).

I've never done this before, so my current questions / concerns are:

  • How do I set up networking in containers so that each developer can access through their own domain? Example: dev1.box.com (will have access to cont_dev1), dev2.box.com (will have access to cont_dev2), etc.
  • I am afraid that if I start Apache | Nginx webserver, will I need to map each of the docker containers to a different port or am I wrong?

I'm sure my guess is correct in the second question, but for the first I don't know how to achieve it. Any example will help me a lot and I will be very grateful.

+3


source to share


1 answer


You can create a docker machine for each of the developers in the developer box with

$ docker-machine create

(Docs: https://docs.docker.com/machine/reference/create/ )

How to create a docker machine which you can read here: https://docs.docker.com/machine/get-started/

After that, each developer can connect to their docker machine via ssh using

$ docker-machine ssh <machineName>



teams. (Docker Docs: https://docs.docker.com/machine/reference/ssh/ )

It should also be possible to use a machine in a dev block, for example local, using

$ docker-machine env

Command. (Docker Docs: here: https://docs.docker.com/machine/reference/env/ )

Hope this helps or gives you an idea of ​​what you can do.

Best wishes Kalle

+3


source







All Articles