Use the -d flag with run command.
EG:
eval $(docker-machine env feature)
docker-compose -f delivery.docker-compose.yml run -d rails rake db:seed
Take care of you disk space.
docker system prune
For each change in Gemfile you have to :
docker-compose build myapp
This will ensure that the gem versions within you Image and containers will be updated according to gemfile
docker-compose run --no-deps myapp bundle install
This will ensure that the Gemfile.lock from your local filesystem will be updated according to Gemfile.
( Require docker-compose >= 1.5 )
Do not edit the docker-compose.yml. Create a docker-compose.override.yml file and place your setup within. ( and please do not commit this file )
See https://docs.docker.com/compose/extends/
Within your docker-compose.override.yml mount the source sql file within the container entry point.
Eg:
pctdb:
volumes:
- ../db_pct_20151228.sql:/docker-entrypoint-initdb.d/init.sql
See https://hub.docker.com/_/mysql/
Then within your docker-compose.override.yml mount the volume container and configure bundler to use the mounted sources.
EG:
app:
environment:
BUNDLE_LOCAL__GEM_NAME: /gem_name
volumes_from:
- gem_name
volumes:
gem_name:
driver_opts:
type: none
device: /absolute/path/on/your/system/for/gem_name
o: bind
Let say for any reason that you want to add a dependency your development environment ( like a custom debugger or profiler … )
First ensure your Gemfile contain something like this:
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
if File.exists?(local_gemfile)
eval_gemfile local_gemfile
end
Then add the gem to the Gemfile.local file
gem 'rmagick'
Then create a Dockerfile.local
FROM foo/develop/etm
apt-get update && apt-get install libimagemagick
ADD Gemfile
ADD Gemfile.lock
ADD Gemfile.local
RUN bundle install
Then in your docker-compose.override.yml
rails:
dockerfile: Dockerfile.local
Within your .zshrc at the end or in a sourced library file add
docker_machine_set () {
eval $(docker-machine env $@)
export RPROMPT='%{$fg[red]%}${DOCKER_MACHINE_NAME}%{$reset_color%}'
}
alias dms=docker_machine_set
to get the current machine name in the prompt use the alias or function to set the machine EG:
dms staging.synbioz.com
You can set the client api version through env var DOCKER_API_VERSION
EG:
DOCKER_API_VERSION=1.22
Add a logrotate conf to the system with the following :
# /etc/logrotate.d/docker-container
/var/lib/docker/containers/*/*.log {
rotate 7
daily
compress
size=1M
missingok
delaycompress
copytruncate
}
Within your dockerfile:
# Allow to install gem in parallel
ENV BUNDLE_JOBS 3
Within docker file
# Configure ruby gem ( see .gemrc for options )
ADD .gemrc /root/
At the root of the context within .gemrc
---
:update_sources: true
:benchmark: false
:backtrace: true
:verbose: true
gem: --no-ri --no-rdoc
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri