A Container Server is a CoreOS specialized virtual appliance that is lightweight and highly scalable. The tools required run Docker containers are installed, and LetsCloud exposes the ability to manage cloud-config via the LetsCloud web interface.

Requirements

  • A single Container instance (1 GB of RAM will work fine)

Running a Docker container server

Let’s first look at how we can run a container server via cloud-config. This isn’t a complete example of a cloud-config (it doesn’t really make sense to deploy a single container inside a single container server. ) but it shows the basic framework you need to get your own containers up and running.

Here’s the example cloud-config:

#cloud-config

coreos:
 units:
  - name: docker.service
   command: start

  - name: dockerapp.service
   command: start
   content: |
    [Unit]
    Requires=docker.service
    After=docker.service
    [Service]
    ExecStart=/usr/bin/docker run -d -p 80:80 nginx

Let’s break this down into parts. All cloud-configs start with ‘#cloud-config’ to denote that it’s a cloud-config file. After that, we have the ‘coreos’ section which allows you to configure different services under the CoreOS operating system, including the ‘units’ sub-sections for individual services.

Inside that sub-section we are required to add at least ‘name’ and ‘command’ fields for each service we want to run. The follow will start the Docker server within the container server:

  - name: docker.service
   command: start

Next we will create another service section with ‘dockerapp.service’ to start a Docker container, and this time we will create a ‘content’ section to provide further parameters:

  - name: dockerapp.service
   command: start
   content: |

Inside the content section we will configure parameters in two different sections. First we will set the ‘[Unit]’ section to tell this service to wait till after the ‘docker.server’ has started, and that it’s required to run this service. This is done using the following lines:

    [Unit]
    Requires=docker.service
    After=docker.service

Then under the ‘[Service]’ section we will tell the system to start a nginx docker container that will listen on port 80 of the container server, and translate to port 80 inside the container. This is done by running the following commands:

    [Service]
    ExecStart=/usr/bin/docker run -d -p 80:80 nginx

Running containers via command line

Now let’s look at how we can run containers via the command line. Inside a Container Server that is already running the Docker server, you can start the same nginx docker container by running the following command:

$$$$

docker run -d -p 80:80 nginx :::Output 2becd010bc539... :::

If you want to view a list of docker containers running you can use:

$

docker ps

Some other commands that may be of use are:

  • Will show a list of Docker containers including exited/failed
$

docker ps -a

  • Will show the logs of that Docker container
$

docker log

  • Will show you the ‘top’ command of that Docker container
$

docker top

  • Will stop that Docker container
$

docker stop

  • Will kill that Docker container
$

docker kill

Conclusion

I hope this provide you with enough information to get started with Container Servers.