5

I'm a recent user of docker and I am about to migrate from VM to containers in my production environment. But then, I suddenly realize that what works perfectly for my dev and qa environments is not ideal for production.

On my dev and qa, I mount my versioned project folder into a python/php (name it) container and I consider this container as a "running service" for my code. This saves me from having huge containers as the container history doesnt change when I change my code (git commit or else).

In production, the ideal case is that I will have clean self contained containers with my code inside, not mounted like I do in dev.

So, did I get it wrong? How do you do it? Do you use the same containers from dev to prod?

errordeveloper
  • 6,716
  • 6
  • 41
  • 54
VsM
  • 710
  • 1
  • 10
  • 23
  • 2
    I ran into the same considerations and took a similar approach. I have a "base" image that contains all the libraries, packages, etc. From that I create a -dev and a -prod variation. Dev expected code to be mounted inside, Prod uses git clone or git pull on restarts. Seems to work. – user2105103 Oct 31 '14 at 17:00

2 Answers2

2

I do the same for in my development environment. I have a production Dockerfile that ADDs the project folder and then I run all the tests against it. Since the only difference between the development container and the production container is when the code is added to the container, not the code or settings, they have the same behavior.

Barry MSIH
  • 3,525
  • 5
  • 32
  • 53
Javier Castellanos
  • 9,346
  • 2
  • 15
  • 19
0

indeed you can do this by add an additional arguments called -v when you run it

sudo docker run -i -t -v /home/ubuntu/my_code:/home/mydocker/my_code ubuntu/my_docker /bin/bash

Awan
  • 5
  • 1