Installing and deploying containers using docker-compose

In this tutorial we will walk through the process of creating a wordpress docker container stack using a docker-compose to build the entire container stack. This tutorial will also cover installing docker-compose on both a box running boot2docker as well as running docker-compose on CoreOS.

Docker Compose
Docker Compose Installation
Docker Compose Bash Completion
Brew Homepage

Click Here for the full Step By Step Text Tutorial

Step by Step Guide:
———————

1. Make sure that you have boot2docker already setup, or are running on a machine that already has docker installed on it. If you do not, then check out the tutorial on how to get boot2docker setup here.

2. Once you have verified that you have either boot2docker installed and running or Docker running, then go to the Docker Compose Installation Page and copy the following 2 commands that are needed to install Docker Compose.

Note: You will need to run these commands as root, which can be done using:

sudo su -
curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Note: Before pasting the curl command, verify that the destination path (/usr/local/bin/ does exist. If not change the destination directory in the curl command to another directory that exists within your path. You can check your path by typing:

 echo $PATH 

3. You can optionally install bash completion for docker-compose by running the following:

Linux – Just install bash completion for docker-compose:

curl -L https://raw.githubusercontent.com/docker/compose/1.1.0/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose

OSX – Install Brew, Install bash completion, Install bash completion for docker-compose:

  • Brew
  • ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  • Bash completion
  • brew install bash-completion
  • Bash completion for docker-compose
  •  
    curl -L https://raw.githubusercontent.com/docker/compose/1.1.0/contrib/completion/bash/docker-compose > /usr/local/etc/bash_completion.d/docker-compose 
    

    4. Now that docker-compose is installed, the next step is to either create your own, or copy an existing yaml file and paste it into a directory. The name of the directory will be the identifier for the application stack, so for example if we are bringing up a wordpress stack using an existing docker-compose.yml file, then I would create a directory named wordpress, open a file named docker-compose.yml and paste the yml contents into that file and save it:

    cd ~/Documents
    mkdir Docker
    cd Docker
    mkdir wordpress
    cd wordpress
    vim docker-compose.yml
    
    dbdata:
      image: appcontainers/centos66
      hostname: dbdata
      stdin_open: true
      tty: true
      restart: always
      volumes:
      - /var/lib
      command: /bin/bash
    
    db:
      image: appcontainers/mysql
      hostname: db
      stdin_open: true
      tty: true
      restart: always
      volumes_from:
      - dbdata
      environment:
      - MYSQL_USER=appadmin
      - MYSQL_PASS=adminpassword123
      command: /bin/bash
    
    web:
      image: appcontainers/wordpress
      hostname: wordpress
      stdin_open: true
      tty: true
      restart: always
      ports:
      - "80:80"
      - "443:443"
      links:
      - db
      environment:
      - MODE=remote
      - APP_NAME=testwordpress.com
      - APACHE_SVRALIAS=www.testwordpress.com localhost
      - MYSQL_SERVER=db
      - MYSQL_CLIENT=172.17.%.%
      - MYSQL_USER=appadmin
      - MYSQL_PASS=adminpassword123
      - MYSQL_DB=wordpress
      - APP_USER=appuser
      - APP_PASS=apppass
      - WP_KEY=ILoveFlappyjacks
      command: /bin/bash
    
    :wq!

    5. Now that I have my yaml file and docker-compose all set up, in order to run the application stack all I need to do is run the docker-compose statement to start the stack:

    docker-compose up -d

    Note: Remember that docker-compose is aware of the application stack by the yml file that it is reading. This means that within the wordpress directory, issuing docker-compose statements will affect the wordpress stack only. If another stack is running, then I would have to cd into the directory where the other docker-compose.yml file lives and issue docker-compose statements against that file, which would in return affect that stack, and not the wordpress stack.

    0 comments

    Trackbacks

    1. […] If your looking for additional information on installing docker-compose, then read the Tutorial on installing and running docker-compose […]

    2. […] If your looking for additional information on installing docker-compose, then read the Tutorial on installing and running docker-compose […]

    3. […] Previous PostInstalling and deploying containers using docker-compose Docker Next PostAppcontainers/Mediawiki Container Repos (function() { var a=this;var b,c,d,e,f;function g(){return a.navigator?a.navigator.userAgent:null}f=e=d=c=b=!1;var h;if(h=g()){var i=a.navigator;b=0==h.indexOf("Opera");c=!b&&-1!=h.indexOf("MSIE");e=(d=!b&&-1!=h.indexOf("WebKit"))&&-1!=h.indexOf("Mobile");f=!b&&!d&&"Gecko"==i.product}var j=c,k=f,l=d,m=e;var n;if(b&&a.opera){var o=a.opera.version;"function"==typeof o&&o()}else k?n=/rv:([^);]+)()|;)/:j?n=/MSIEs+([^);]+)()|;)/:l&&(n=/WebKit/(S+)/),n&&n.exec(g());var p=document,q=p.createElement("link");q.rel="stylesheet";q.type="text/css";q.href="http://zor.fyre.co/wjs/v3.0/css/livefyre_"+(m?"mobile":"embed")+".css";q.media="all";p.getElementsByTagName("head")[0].appendChild(q);var r="header hgroup footer article section aside nav figure figcaption embed audio video canvas details summary time mark".split(" "),s=p.createDocumentFragment(),t;for(t=0; t […]

    4. […] PostAppcontainers/SAMBA Demo Demos Next PostInstalling and deploying containers using docker-compose […]

    5. […] If you need assistance setting up docker-compose please visit http://www.appcontainers.com to watch the tutorial or read about the installation […]

    6. […] If you need assistance setting up docker-compose please visit http://www.appcontainers.com to watch the tutorial or read about the installation […]

    7. […] If you need assistance setting up docker-compose please visit http://www.appcontainers.com to watch the tutorial or read about the installation […]

    8. […] Appcontainers/Hubot | AppContainers.com on Installing and deploying containers using docker-compose […]

    9. […] Appcontainers/Hubot | AppContainers.com on Installing and deploying containers using docker-compose […]

    10. […] If you need assistance setting up docker-compose please visit http://www.appcontainers.com to watch the tutorial or read about the installation […]

    11. […] appcontainers/rundeck | AppContainers.com on Installing and deploying containers using docker-compose […]

    12. […] appcontainers/rundeck | AppContainers.com on Installing and deploying containers using docker-compose […]