Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having a bit of a difficult time understanding how I can leverage my existing infrastructure code with Docker.

I have a Ruby on Rails app that uses capistrano to push out deployments. I want to use this capistrano script to create a new docker image. Can I push out a deploy and then use the deployed to directory to deploy on top of an existing image say, precise (since that matches my target OS).

Would this be the right approach or am I missing something?

share|improve this question
1  
If you want to continue using capistrano to deploy your application, what role do you see docker playing? – sciurus Mar 10 '14 at 0:32
    
@sciurus My application exists in two states - checked out from git for "development", or "deployed" via capistrano. I'm not sure how the "deployed" version differs from the "development" version. I want to take the "deployed" version and dockerify it. Then to "deploy" to other machines I could pass the docker image around. – EightyEight Mar 10 '14 at 4:31

Usually in Docker the preferred way to deploy an application in a container is by a dockerfile, that can replace the role of a capistrano script, mainly running commands on the container (install packages, perform git clone, start services and applications and so on).

You define a dockerfile with a base image container and a list of commands to execute and then you build your container by:

docker build {{your_repository_containing_dockerfile}}

So you can translate your capistrano script to a dockerfile and replace Capistrano deploy with Docker deploy.

share|improve this answer

@EightyEight

We are using docker and Jenkins to do the deployments. We keep our code always out of docker till the time we want to release and run it.

You should have Docker Image available on all the servers/instances where you want to deploy the application.

You should do the complete deployment in two steps.

1) Have a Job in Capistrano to build a package (tar or gz) for the tag/branch of you application you want to deploy.

2) Have another job to do the actual deployments in following steps:

i) Push the package to all the servers you want to deploy the application on & untar the package.

ii) Stop if any container is already running for the same application and run the container with the appropriate container and code mounted onto it.

For e.g. docker run -d -p 8000:8000 -v /path/to/the/tag:/deployment/path/inside/docker --name (NameOfContainer) --env TERM=xterm accountid/imagename:version

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.