Should I use devmon with docker?
Sure! devmon will give you the benefits of managing your docker containers on a per-project basis, and manage it using a easy UI.
How we do it?
Docker is different. it acts as a deamon. there is a command for starting up a container, stopping a container and showing logs.
Thats why we have an
Is Deamon Option inside of devmon.
this option allows you to set 3 commands for each world case.
Using Is deamon Option for Docker command
Ok, so let’s take an example.
When we click the start button, we want to start the docker image
We would like it to bind port 80 to 3000 in our host & We would like it to mount our current working directory as the root html folder of our apache server.
Also, we would like to delete the container after it is stopped.
The Start Command
docker run --rm -d --name devmon-apache-php5 -p 3000:80 -v `pwd`/:/web/html nimmis/alpine-apache-php5
--rm – will remove the container after the process has stopped.
-d will start the container in deamon mode.
devmon-apache-php5 – thats our container name, give it. we want to give it a friendly name, because we will refer to this name in our stop and logs command.
-p 3000:80 – we want to bind container port
80 to host port
-v – this will bind our current working directory to the container’s html root.
Now we are able to start the docker container.
The Stop Command
To stop the container all we need to do is setup this command as our Stop Command
docker stop devmon-apache-php5
--rm option will make sure that the container is deleted, and we have cleaned our state, so we can start the same container again any time.
The Logs Command.
Here this will get a little tricky, as we have two options:
Option 1 – Docker Logs
that’s the easy option.
Set in the logs command
docker logs devmon-apache-php5 and you are up and running.
Option 2 – Image Specific Logs
This is, in my opinion, the more useful option.
With this option, we can tell devmon to run our application specific logs.
In our example, this docker image will emit the access.log and error.log files in
So we will use this Logs command:
docker exec -it devmon-apache-php5 sh -c 'tail -f /web/logs/error.log -f /web/logs/access.log'
Let’s explain whats going on:
docker exec -it devmon-apache-php5 – We will run a command in an existing container. we want to run in in interactive mode, so we can see the output in real time. we are running it in the same container we’ve started before.
sh -c – we want to run a
'tail -f /web/logs/error.log -f /web/logs/access.log' – that’s our tail command.
this will tail and follow the logs produced by our application, and show it in the logs window.
We are ready to use Docker with devmon!