In this guide, you'll set up Docker on a Ubuntu 18 instance running on Civo. This will allow you to run applications in self-contained containers that you can deploy at will.
You can create an instance easily through the dashboard once you're logged in.
Log in to your instance using
ssh and the username/password or SSH key you specified when you created it.
Remove any older versions of Docker and install the dependencies:
$ sudo apt remove docker docker-engine -y $ sudo apt install apt-transport-https python-setuptools python-pip software-properties-common -y
Set up the needed repository for Docker Community Edition through the command line:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ sudo apt-key fingerprint 0EBFCD88 $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Update the repository index and Install Docker Community Edition:
$ sudo apt update $ sudo apt install docker-ce -y $ sudo pip install docker-compose
Enable Docker on Startup and Start the Docker Engine:
$ sudo systemctl enable docker $ sudo systemctl restart docker
If you would like to execute your docker commands without sudo, add your user to the docker group:
$ sudo usermod -aG docker $(whoami)
Test your Setup by Running a Hello World Container. You will see that if the image is not in the local docker image cache, it will pull the image from docker hub (or the respective docker registry), then once the image is saved locally, docker will then instantiate the container from that image:
$ sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 78445dd45222: Pull complete Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly.
You will now be able to deploy applications in containers using Docker. For next steps with Docker, check out this article on Dockerizing a Rails application, or this one on setting up a 3 Node Docker Swarm.
✅Follow Civo on Twitter!