Installing Docker

We need to have a target for deployment. In real life, this would be some sort of image of a VM/container, but here we will run a Docker container locally and deploy code on it. To run an Ubuntu container, use the following:

docker run -p 9000:9000 -p 32:22 -it ubuntu /bin/bash

This command will deploy an Ubuntu container and name it Ubuntu. It will also perform a couple of port mappings to allow for ssh and access to the HTTP server (which runs on port 9000).

We will be using SSH to transport artifacts onto the deployment target. Hence, we need to install the ssh server on the container. One can do this using the following commands:

apt-get update
apt-get install openssh-server

service ssh restart

After this, one needs to generate a key pair on the build server (in this case, the dev laptop) :

ssh-keygen -t rsa

After this, we need to copy the public key (~/.ssh/id_rsa.pub) contents into ~/.ssh/authorized_keys on the target server (which in this case is the Ubuntu container). Make sure your .ssh dir has 700 permissions and the authorized_keys file has 644 permissions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset