Docker Community Forums

Share and learn in the Docker community.

Need advices : best way to change container code, configure mysql, run multiple containers on different urls


This post is a bit special. I have no technical difficulties with docker (yet). Instead, I’m trying to figure out what a good docker installation should look like, taking into account best practices and common use cases. I am completely new to the docker world and would need advice from experienced people. I have tried to answer my own questions, Q&A style, and I would like to know if you have any comments or suggestions on this:

I have a very small change to make in my code (let’s say change the color of a button), what is the procedure?

From my research, editing the code of a running container can be done using a docker volume, but it’s considered bad practice. The best option would be to stop, update the image, and rebuild the container. These operations being cumbersome, it is preferable to modify the code in a development environment before deploying it on the docker instance. Is it correct ?

My application is based on mysql. When I deploy my app to a new server, I usually log into the server, run the mysql install, and create a user with a chosen password. I clone my app code to its destination folder, then edit a config file (which is ignored by git) in my app code to indicate mysql logins. I would then create the dabatase by running a sql script. How would that work in a docker context?

The solution would be to:

  • git-clone the application code in its destination folder
  • choose the mysql password
  • edit the application configuration file
  • edit the docker-compose.yml file to indicate the user and the password in the mysql environment
  • create a folder next to my docker-compose.yml file called “init” and place my mysql scrit there
  • edit the docker-compose.yml file to indicate the volume ./init:/docker-entrypoint-initdb.d
  • build the image, build the container
    Is this a good approach?

How to manage URLs when several instances of my application are installed on the same server (apache)? For example link1 for the container named instance1 etc, link2 for the container named instance2 etc …

I need to run each container on a specific port, ex:
instance1 → 3000
instance2 → 3001
Then in apache conf I need to configure a reverse proxy, like this:

<VirtualHost *: 80>
  Server name link1

  <Location />
    Order, allow, deny
    Allow of all
    Require everything granted

  ProxyPass /
  ProxyPassReverse /


(same thing with link2 …)
Is this the right approach?

Thanks in advance for your time.