Report this

What is the reason for this report?

Help understanding the deployment process to a droplet using Docker

Posted on April 1, 2020

Hi,

I have a Rails-based web application which I am running locally on a development machine which uses Docker Desktop for mac.

The application comprises of several services, and have used a docker-compose file to co-ordinate.

To get to this point I have been using the book, Docker for Rails Developers as a guide.

It has also been helpful in guiding me to adapting the code for a production environment by creating a Dockerfile.prod with some production specific behaviour.

I have also uploaded the relevant docker images for my web app and another service to Docker Hub so they are available to use.

But here is where I am getting stuck.

The book refers to using docker-machine to continue this process, to create the Digital Ocean instances, a docker-stack.yml file and then deploy.

But this looks to be out of date because reading the Docker documentation docker-machine has been superseded and is no longer the correct approach.

For the moment I would just like to make a very simple deploy to a droplet to see the site running and then be more ambitious with the scaling once it is working.

My question is—how can I achieve this?

I find lots of tutorials, and there is a great one on this site, for setting up Docker with Rails—but so far no clear explanation for taking that working application and then actually deploying it to Digital Ocean.

This seems like the best one online I’ve found, but is from 2016, and includes docker-machine as well.

My instinct is that I could set up the droplet with Docker pre-installed and then run docker-compose from the command line there, where it can pull the images from Docker Hub directly,… but in which case how would I share the docker-compose (or docker-stack) file?

I feel like I am missing an important piece of the puzzle and it has got me really stumped.

Any recommendations or just an explanation for the best way forward very much appreciated!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello,

The easiest way to deploy your Dockerized application to a DigitalOcean Droplet would indeed be to use Docker Compose directly on the Droplet. You can do this in a few steps:

  1. Setup a Droplet: You can create a new droplet on DigitalOcean. Choose the Docker image from the Marketplace, which comes with Docker and Docker Compose pre-installed:

https://marketplace.digitalocean.com/apps/docker

  1. Transfer Files: After your droplet is up and running, you’ll need to transfer your application files (including Dockerfile, docker-compose.yml, and your application code) to the droplet. You can use a tool like scp or rsync or use Git to clone your GitHub repository on the Droplet.

  2. Run Docker Compose: SSH into your droplet (ssh root@your_droplet_ip), navigate to the directory where you transferred your application (cd /app), and then bring up your Docker containers with Docker Compose:

docker-compose up -d

The -d flag tells Docker Compose to run the containers in the background.

That’s it! Your application should now be up and running on your Droplet.

However, note that this setup requires manual intervention for tasks like deployment, scaling, and updates. If you’re looking for a more managed solution, you might want to consider the DigitalOcean App Platform.

The DigitalOcean App Platform is a Platform as a Service (PaaS) that allows you to build, deploy, and scale apps quickly using a simple, intuitive interface. You simply point the App Platform to your GitHub repository, and it handles everything from building and deploying your app to managing and scaling the underlying infrastructure. The App Platform also supports Docker, so you can deploy your Dockerized application without any modifications.

Keep in mind that using the App Platform does involve additional costs, but it might be worth considering if you’re looking for a more hands-off approach to managing your infrastructure.

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.