Last Updated: September 23, 2016
· jpanganiban

Server Deployments on Ubuntu with Docker and Supervisor

We'll use supervisor to manage docker containers in our host machine.


Install Docker and Supervisor via apt. There's a mirror that contains the latest version of docker.

$ sudo apt-key adv --keyserver hkp:// --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

$ sudo sh -c "echo deb docker main\
> /etc/apt/sources.list.d/docker.list"

$ sudo apt-get update
$ sudo apt-get install lxc-docker

Here's a complete guide on how to install docker:

Configuring Docker

Update /etc/default/docker and add the following line:


This stops docker from auto-restarting containers that failed to start. We'll let supervisor manage that for us.

Supervisor Configuration

Write a supervisor configuration for your application and save it in /etc/supervisor/conf.d/.

Here's an example supervisor configuration for your app

command=docker run --name myapp -a stdout -a stderr --rm=true -p 3000:3000 -v /home/ubuntu/deploy:/app -e PORT=3000 me/myapp python

Command Arguments Used

  1. --name sets our container's name.
  2. -a stdout -a stderr gets the internal process' stream so we can use supervisor to log.
  3. Stopping a container does not delete it. --rm removes the container once it's stopped.
  4. -p 3000:3000 forwards our host's port 3000 to our container's port 3000.
  5. You can set environment variables inside the container. ie. -e PORT=3000

2 Responses
Add your response

Are stopped containers removed by using --rm flag, using supervisord as a provisioner for docker containers? In my case, old containers are not removed,
even when I use --rm flag.


over 1 year ago ·


Wanted to know if --rm flag in the command above does remove the container after it has been stopped? Because i am not seeing that behaviour.


over 1 year ago ·