Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I need to setup a developer box using Docker and this mean I will have:

  • different containers running the same environment
  • different developers accessing each of those containers

This is a setup where multiple containers will be running in a "central server" and the developers will connect to this "central server" thru SSH or Samba or any other way (not defined yet).

Take this as an 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 a domain assigned to the external IP address to the "central server".

The idea behind this is not to install the development tools on the server itself so we can use the advantages of Docker (switching between tools easily for just mention one).

I have never did that before so my currently questions/problems are:

  • how should I setup the network on the containers so each developer access through his own domain? Ex: dev1.box.com (would access cont_dev1), dev2.box.com (would access cont_dev2) and so on
  • I am afraid if I am running Apache|Nginx webserver I will need to map each of the docker containers to a different port or I am wrong?

I am pretty sure my guess is right on the second point but for the first one I don't have a clue in how to achieve it. Any example will help me a lot and I'll be very grateful.

like image 301
ReynierPM Avatar asked May 03 '17 14:05

ReynierPM


1 Answers

You could create a docker-machine for each of the developers on the developer box with

$ docker-machine create

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

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

After you did that, each developer could connect to his docker-machine via ssh, by using the

$ docker-machine ssh <machineName>

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

Also it should be possible, to use the machine on the developer box like his local one by using the

$ docker-machine env

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

Hope that helps or gives you an idea what you could do.

Best Regards, Kalle

like image 90
friiky Avatar answered Sep 22 '22 09:09

friiky