Posted on Leave a comment

Docker Compose – The minimalist instructions

The first pieces of how to use Docker Compose

What is Docker Compose

For me, docker-compose is a case study in the right tool for the right job. At the least, it allows us to carefully manage and maintain the instancing of our containers. docker-compose takes the command-line options for docker and places them into configuration files.

Installing Docker Compose

The Official Install Instructions

If you want to go straight to the source head over to the docs.docker.org install here Install Docker, There you will find comprehensive ( but not overly so ) instructions on Install/Upgrade and Remove. The author did a great job keeping it concise yet thorough

Installing a Distro verion:

If you are lucky and you already have installed docker you can likely install docker compose from your distro simply with:

apt install docker-compose

( use sudo if you are not admin )

Installing the most recent version:

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Make it executable

sudo chmod +x /usr/local/bin/docker-compose

Make it visible to bash for tab completion.

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Test it out:

docker-compose -version

First Run

Official Documentation – The folks over at docs.docker.com have provided a well-written set of instructions on using docker-compose. If these instructions do not work for you, head over there and get it from the source.

The Configuration File

Using your preferred editor create a file and call it docker-compose.yml ( the name is arbitrary, you can call it anything just end it with .yml ) This is a very basic config file and you will likely expand. This gets you started

wordpress:
     image: wordpress
     ports:
      - "8083:80"

Or, here is a printf piped into the file to make it easier, copy this to your command line and hit enter.

printf "wordpress:\n\timage: wordpress\n\tports:\n\t - \"8083:80\"\n" > docker-compose.yml

Issue the compose up command

docker-compose up -d

The output will show you ( hopefully ) the name and status of your new container

Creating docker-wordpress_wordpress_1 … done

This WordPress container is not connected to a database so it is of limited use, it is just a nice easy way to learn the very basics of docker-compose.

Conclusion

This set of instructions chronicles my steps us docker-compose the very first time. The idea is to learn the very basic requirements before adding complexity. I enjoy capturing my journey in article form. My approach helps reinforce the knowledge, I am hoping helps you as well. This example certainly does not constitute a deployment-ready solution. This example is simply fodder for learning. I hope you learned as much as I did.

Leave a Reply