Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running and Deploying Rails to Docker Container

Tags:

I am a total noob to linux containers and been spending some time learning about Docker, and forgive my confusion thought this question. Currently, I have a Rails app in production deployed via capistrano. My cloud servers are maintained with Opscode Chef on the Debian Wheezy distribution. For development, I have a Vagrant VM preinstalled with the app and services.

If I were to employ Docker, where would my app sit? The container or the host? How would I deploy (production) and share directories (development)? Can I run all my additional services ie memcache, redis, postgresql, etc on the same server using docker? I can maybe envision the potential of Docker but having trouble seeing its practical use.

Seems like containers are part of the future. Any guidance for someone making the switch from virtualization?

like image 643
Jahkobi Digital Avatar asked Aug 06 '13 23:08

Jahkobi Digital


People also ask

How do I run a Rails program in Docker?

In your terminal, change your directory to the docker-rails directory and run the following command: >_ docker build -t rubyapp . To create a container from this image, run the command docker run -p 3000:3000 rubyapp . This creates a container and binds port 3000 of your host computer to port 3000 of the container.

Can I use GPU in Docker?

To use your GPU with Docker, begin by adding the NVIDIA Container Toolkit to your host. This integrates into Docker Engine to automatically configure your containers for GPU support. The Container Toolkit should now be operational. You're ready to start a test container.

How much RAM should I allocate to Docker?

Limit a container's access to memory The maximum amount of memory the container can use. If you set this option, the minimum allowed value is 6m (6 megabytes). That is, you must set the value to at least 6 megabytes. The amount of memory this container is allowed to swap to disk.


2 Answers

If I were to employ Docker, where would my app sit?

It could sit inside the container or it could sit on the host(you can use docker build to copy the app into the container)

How would I deploy (production) and share directories (development)?

Deploying your app would mean committing your local container into an image, publishing it and running a container out of the published images on your servers. I have not tried sharing directories between host and container, but you can try this : https://gist.github.com/jpetazzo/5668338 . You can also write a Dockerfile which can copy a directory to a target in the container. Docker's docs on building images will help you there.

Can I run all my additional services ie memcache, redis, postgresql, etc on the same server using docker?

Yes. You will be running multiple containers on the same server.

like image 69
Emil Avatar answered Oct 20 '22 22:10

Emil


I'm no expert and I haven't even used docker myself, but as I understand it, your app sits inside a docker container. You would deploy ideally a whole container with your own ruby version installed and so on.

The big benefit is, that you can test exactly the same container in your staging system that you're going to ship to production then. So you're able to test the complete system with all installed C extensions, the exact same ls command and so on.

like image 27
udo Avatar answered Oct 21 '22 00:10

udo