Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy a docker container to production

I have create a docker image on my dev machine and tested my RAILS code on it. The container uses code from the host this way :

docker run -v [/path/to/dir/to/mount/on/local/machine/]:[/desired/path/in/docker/] -p [port to forward] -i -t [name of image] /bin/bash

Now I would like to push the container to a preproduct environment and then a production environment.

What is the best way to do that ? Should I install docker on the preprod/prod servers and then use the image ?

Or should I configure my staging to be identitical to my image and upload my source code ?

like image 820
user2854544 Avatar asked Oct 08 '13 16:10

user2854544


People also ask

Can Docker be used in production?

In short: Docker is only as safe as its users' implemented safety measures. Technically, it can be used in production. When it comes to safety, Docker's come a (really) long way since its early days.

Can containers be used in production?

Docker pioneered the containerized application model in 2013, and is still the most popular container engine. Containerized infrastructure is a large and growing market, estimated to reach $4.3 billion by 2022. According to the CNCF Survey 2020, use of containers in production increased to 92% in 2020.


1 Answers

Are you deploying a rails app? I would take a look at Dokku which is basically a self hosted version of heroku.

If you want to use docker directly I would take a look at using a deployment script of some type to help you with this. Basically it can login via ssh, git clone the code to a directory and then run the docker image with the new directory (stopping any existing instances). But again Dokku makes this way simpler.

like image 166
Austin Lin Avatar answered Nov 13 '22 00:11

Austin Lin