anynines website

Categories

Series

Benjamin Guttmann

Published at 17.01.2016

How-To’s & Tutorials

Getting started with Concourse CI and Docker – Part 1

Welcome to the first part of our series about Concourse CI and Docker.

The main purpose of this series is to explain you what Concourse CI is and how to use it. During the different posts we will build two example pipelines, one to manage your Docker images and another for building and testing a sample application. Since Concourse CI is using containers, we will take the chance to give you a brief introduction of using Docker.

This part provides you the general information of Concourse CI and a small „Getting started“ for Docker.

Table of Contents

What is Concourse CI?

As the CI in the name Concourse CI implies we talk about a system for continuous integration. We could do continuous deployment (CD) with Concourse as well – we will do so later on. The question is, what differs Concourse CI from the other products you know?

Concourse CI is designed to be simple, you should not spend lots of time to get to know your CI system, you should devote your time to developing applications. The idea of Concourse is that the best tools can be learned in one sitting. To ensure this, Concourse defines just three basic elements that can express arbitrary features and pipelines. To get to know more about them at this point, check out the Concepts.
We will develop this topic in a subsequent post.

Concourse is optimized for quick navigation through your pipelines and logs of your jobs.

Now, as Concourse is statically configured, you can recreate it from scratch with a single bosh deploy, that also means  that if your deployment’s infrastructure burns down, just deploy somewhere else. In addition to this, scaling up is as easy as ABC, just adjust the number of workers in your BOSH deployment manifest, scaling down is similar to that.

One of the coolest features of Concourse CI is perhaps the possibility to create pipelines. These pipelines consist of resources and jobs. You can chain different resources and jobs together, so you can configure your pipeline in that way, that if a resource, used by a job, is changing, the job is executed automatically.

To keep the core of Concourse small and simple, special features are provided to the user, as resources,

  • Timed build triggers
  • Integrating with Git repositories
  • Auto-delivering stores in Pivotal Tracker
  • Building a pipeline for Docker images

just to name a few of them.

Getting started with Docker

Now, you will get to know about :

  • installing Docker on your system
  • what is Dockerfile
  • start your first container and access it

So, let’s start with installing Docker on your machine.
These guides are based on the official Docker Guide ( please check it out for new versions ).


If you see this, you can start working with Docker ;-)

Mac OS X

There is also a „brew-way“ of installing Docker Toolbox, just use Step 2b instead of Step 2a.

Step 1: Check your version of Mac OS X

To get to know your current version of Mac OS X you should

  1. hit the Apple Symbol in the top-left corner of your screen
  2. choose ‚About this Mac‘ from the menu
  3. find your version right under „OS X“

for the current version you need Mac OS X 10.8 „Mountain Lion“. So, if everything is okay, let’s move on.

Step 2a: Install the Docker Toolbox
  1. Go get the Docker Toolbox
  2. Install the Docker Toolbox
Step 2b: Install the Docker Toolbox with Homebrew

To install GUI Mac applications you need Homebrew-Cas,and don’t worry, its installation is straightforward. Just add the cask tap and install brew-cask.

  1. Check if you already added the cask tap, enter „brew tap“ into the terminal and search the line „caskroom/cask“ in the output, if there is such line jump to 3. if not continue with 2.
  2. To add the tap use the command „brew tap caskroom/cask“
  3. Check if brew-cask is already installed, enter „brew list“ and check for „brew-cask“ if it is already there jump to step 5. if not, continue with 4.
  4. Install brew-cask with „brew install caskroom/cask/brew-cask
  5. To install the Docker Toolbox use “brew cask install dockertoolbox”
  6. Go to the Applications Folder and there start Kinematic inside the Docker Folder, this will create a Docker VM in Virtual Machine, you can skip the login to Docker Hub for the moment.

Notice:  !!! Please make sure that there is no VM up and running in VirtualBox while you try to install Docker Toolbox, this can cause the installation to abort. !!!

Step 3: Verify your installation

If you wish to use the GUI to verify your installation use 1a, 1b shows you how to verify your installation simply using the terminal.

  1. a) Launch the Docker Quickstart Terminal Icon. You can do this by open the Launchpad and locating the Docker Quickstart Terminal Icon.
    b) Insert „docker-machine ssh default“, hit ENTER (if Host „default“ is not running => first enter command „docker-machine start default“)
  2. The terminal does a number of things for you, as soon as you see the docker logo you are ready to start.
  3. Type the command „docker run hello-world“ and press RETURN

If everything runs well you should see an output like this:

[code light=”false” language=”bash”]
$ docker run hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
535020c3e8ad: Pull complete
af340544ed62: Pull complete
Digest: sha256:a68868bfe696c00866942e8f5ca39e3e31b79c1e50feaee4ce5e28df2f051d5c
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
https://hub.docker.com

For more examples and ideas, visit:
https://docs.docker.com/userguide/
[/code]

Jump to the next step, Docker Hub.

Linux

This guide uses a terminal for the installation, so please open a terminal to insert the given commands.

Step 1: Verify that wget is installed

To check if you got wget installed

[code language=”bash”]$ which wget[/code]

if you get a path as an answer, everything’s alright and you can switch to Step 2, if you get nothing as an answer please do the following steps.

For Ubuntu/Debian users:

[code language=”bash”]
$ sudo apt-get update
$ sudo apt-get install wget
[/code]

For centOS users:

[code language=”bash”]
$ sudo yum update
$ sudo yum install wget
[/code]

Step 2: Install Docker

To get the latest Docker package use:

[code language=”bash”]
$ wget -qO- https://get.docker.com/ | sh
[/code]

The system may prompt you for your sudo password, and afterwards it will download and install Docker together with its dependencies.

Sometimes it happens that the apt-key command fails during the installation, then you can add the key directly using the following:

[code language=”bash”]
$ wget -qO- https://get.docker.com/gpg | sudo apt-key add –
[/code]

Now you can try the first wget command again.

Step 3: Verify your installation

Insert
„docker run hello-world“ to the command line, to verify if docker is installed correctly.
Yes, it is as easy as that. ;-)
If everything runs well you should see an output like this:

[code light=”false” language=”bash”]
$ docker run hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
535020c3e8ad: Pull complete
af340544ed62: Pull complete
Digest: sha256:a68868bfe696c00866942e8f5ca39e3e31b79c1e50feaee4ce5e28df2f051d5c
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
https://hub.docker.com

For more examples and ideas, visit:
https://docs.docker.com/userguide/
[/code]

Jump to the next step, Docker Hub.

Windows

This guide uses a terminal for the installation, so please open a terminal to insert the given commands.

Step 1: Check your version

Your machine must be running Windows 7.1, 8/8.1 or otherwise it will not run Docker Toolbox.

Step 2: Install the Docker Toolbox
  1. Go and get the Docker Toolbox
  2. Install the Docker Toolbox
Step 3: Verify your installation

If you used the default settings of the installation, you should find the Docker Toolbox Icon on your Desktop.

  1. Click the Toolbox Icon icon to launch the Docker Toolbox terminal.
  2. At start the terminal is doing several things for you. When all things are done, the terminal displays the $ prompt to you.
  3. Type the command „docker run hello-world“ and press RETURN.

If everything runs well you should see an output like this:

[code light=”false” language=”bash”]
$ docker run hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
535020c3e8ad: Pull complete
af340544ed62: Pull complete
Digest: sha256:a68868bfe696c00866942e8f5ca39e3e31b79c1e50feaee4ce5e28df2f051d5c
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
https://hub.docker.com

For more examples and ideas, visit:
https://docs.docker.com/userguide/
[/code]

Docker Hub

A perfect place to search for existing images built by other people is Docker Hub.
There, you can search easily for any image you can think of. These images can be used as they are, or you can base your new image on them, but more on this topic will come out in the next part of this series.
As the first thing we will search for docker’s way of hello world, so enter „whalesay“ in the search bar and hit ENTER.
You will get lots of results for this search term but we are looking for the one and only: docker/wahlesay.
Click on the „Details“-Button and here  you get lots of information:

  1. a short description about the image
  2. the command you need to know to pull the image
  3. a full description
  4. and the owner

Now we can copy the Docker Pull Command (docker pull docker/whalesay) to a clipboard, we will need this in the following step, but first let’s have a look at the pull command:

[code language=”bash”]
docker pull docker/whalesay
[/code]

As you can see, the first word (docker) indicates that this is a docker command, the „pull“ is the action to perform and after this the image is specified the first part names the owner, in our case this is „docker“, and the last part is the name of the image named „whalesay“, the parts are separated by a / .

Running your first container

If your Docker QuickStart Terminal isn’t already running please start it now.

Paste the pull-command from your clipboard into the console or insert it by hand, after that hit ENTER.

At this moment, the terminal is pulling the image with its different layers, after it’s finished you can enter the following command to run your first container:

[code language=”bash”]
docker run docker/whalesay cowsay boo
[/code]

At this moment you should see an output like < boo > and a whale consisting of ASCII symbols.
That’s all. Easy, isn’t it ?

Well, just  one small remark, you can enter the docker run command right at the beginning without the pull command – if docker can’t find an image it will download it automatically from Docker Hub for you.

I think that it is more than enough as for the first part. Next time, I will show you how to build your own Docker images and upload them to Docker Hub.

Read part two of Getting started with Concourse CI and Docker >>

© anynines GmbH 2024

Imprint

Privacy Policy

About

© anynines GmbH 2024