Table of Contents
- Operating System Support
- Virtual Datacenter Setup
- Installing Docker on Ubuntu
- Install nginx and Commit the Image
This tutorial will walk you through the process of installing and validating that Docker is running correctly on your ProfitBricks servers. We will also illustrate how changes and commits work within a container by installing nginx.
Operating System Support
ProfitBricks supports multiple Linux distributions -- some that support Docker, some that do not. The following table outlines the OS images that currently support Docker.
- Ubuntu Trusty 14.04 (LTS)
- Ubuntu Precise 12.04 (LTS)
- CentOS 7
You can assign these images at the time you create a storage volume either through the DCD or via the API.
Virtual Datacenter Setup
Prior to continuing this tutorial it is recommended that you first try this within a test environment. The best way to set one up is by creating a separate virtual datacenter within your account that is fully segmented from your existing ProfitBricks production datacenter. You can do this via the API or Datacenter Designer (DCD).
First drag and drop a new assembly into the main pane. You will want to ensure it looks like the below diagram.
You will want to set the image for the storage volume to Ubuntu-14.04-LTS-server-2014-10-01. The default values for Cores and RAM should be fine for the purposes of this tutorial.
Once you're ready, provision the datacenter.
Installing Docker on Ubuntu
Docker requires the package
apt-transport-https to be installed. This is included in the default Ubuntu-14.04 build at ProfitBricks.
Before you install Docker, you will need to add the Docker repository key to your keychain:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
You should see a response similar to this:
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.tNUh5zx96p --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 gpg: requesting key A88D21E9 from hkp server keyserver.ubuntu.com gpg: key A88D21E9: public key "Docker Release Tool (releasedocker) <email@example.com>" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1)
Next, update and install the
sudo sh -c "echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list" sudo apt-get update sudo apt-get install lxc-docker
Finally, test that Docker is indeed working correctly by issuing the following command.
sudo docker run -i -t ubuntu /bin/bash
Change and Commit the Image
Once Docker is installed and you've shelled into your first container it is time to make a change to the configuration and commit it. We will go ahead and do a default install of nginx.
root@6e39ef6456de:/# apt-get update root@6e39ef6456de:/# apt-get install nginx root@6e39ef6456de:/# echo "daemon off;" >> /etc/nginx/nginx.conf root@6e39ef6456de:/# chown -R www-data:www-data /var/lib/nginx
exit to drop out of the container.
Finally, commit the container:
docker commit 6e39ef6456de nginx-server
Be sure to swap out the container ID with your own.
Confirm your new container image exists:
root@docker001:~# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE nginx-server latest 265400f6aeaa 11 seconds ago 231.3 MB
Go ahead and start up the container:
docker run -d -p 80:80 nginx-server /usr/sbin/nginx
You should see your new image by running:
sudo docker ps
This should show something similar to:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS 5f6ad38bad2c nginx-server:latest "/usr/sbin/nginx" 3 seconds ago Up 3 seconds 0.0.0.0:80->80/tcp
At this point you should be able to make a request using something like
curl to validate that your nginx docker container is indeed serving the default page:
You should also be able to hit the same page from the public Internet using your publicly assigned ProfitBricks IP.