Skip to content

Instantly share code, notes, and snippets.

@numbata
Last active September 11, 2015 11:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save numbata/bf4621910e00a4cf607e to your computer and use it in GitHub Desktop.
Save numbata/bf4621910e00a4cf607e to your computer and use it in GitHub Desktop.
docker-compose patсh
#!/bin/bash
# cat /usr/local/bin/docker-run-ssh
# "docker run" with SSH Agent Forwarding for boot2docker
# QuickStart:
# 1. Download to ~/bin/docker-run-ssh and chmod +x it
# 2. docker-run-ssh [normal args to docker run...]
# Use a unique ssh socket name per-invocation of this script
SSH_SOCK=boot2docker.$1.ssh.socket
# ssh into boot2docker with agent forwarding
ssh -i ~/.ssh/id_boot2docker \
-o StrictHostKeyChecking=no \
-o IdentitiesOnly=yes \
-o UserKnownHostsFile=/dev/null \
-o LogLevel=quiet \
-p 2022 docker@localhost \
-A -M -S $SSH_SOCK -f -n \
tail -f /dev/null
# get the agent socket path from the boot2docker vm
B2D_AGENT_SOCK=$(ssh -S $SSH_SOCK docker@localhost echo \$SSH_AUTH_SOCK)
echo "SOCK ${B2D_AGENT_SOCK}"
# mount the socket (from the boot2docker vm) onto the docker container
# and set the ssh agent environment variable so ssh tools pick it up
# docker run \
# -i -t \
# -v $B2D_AGENT_SOCK:/ssh-agent \
# -e "SSH_AUTH_SOCK=/ssh-agent" \
# "$@"
docker-compose run \
-e DOCKER_VOLUME="$B2D_AGENT_SOCK:/ssh-agent" \
--volume $B2D_AGENT_SOCK:/ssh-agent \
-e SSH_AUTH_SOCK=/ssh-agent \
"$@"
# we're done; kill off the boot2docker ssh agent
ssh -S $SSH_SOCK -O exit docker@localhost
--- cli/main.py 2015-08-24 20:57:57.000000000 +0300
+++ /usr/local/Cellar/fig/1.3.3/libexec/lib/python2.7/site-packages/compose/cli/main.py 2015-07-29 03:04:37.000000000 +0300
@@ -13,7 +13,7 @@
from .. import legacy
from ..const import DEFAULT_TIMEOUT
from ..project import NoSuchService, ConfigurationError
-from ..service import BuildError, NeedsBuildError
+from ..service import BuildError, NeedsBuildError, parse_volume_spec
from ..config import parse_environment
from .command import Command
from .docopt_command import NoSuchCommand
@@ -281,6 +281,7 @@
--entrypoint CMD Override the entrypoint of the image.
-e KEY=VAL Set an environment variable (can be used multiple times)
-u, --user="" Run as specified username or uid
+ -v, --volume=[] volumes
--no-deps Don't start linked services.
--rm Remove container after run. Ignored in detached mode.
--service-ports Run command with the service's ports enabled and mapped
@@ -331,6 +332,12 @@
if options['--user']:
container_options['user'] = options.get('--user')
+ if options['--volume']:
+ old_volumes = service.options.get('volumes') or []
+ new_volume = options.get('--volume')
+ old_volumes.append(new_volume)
+ container_options['volumes'] = old_volumes
+
if not options['--service-ports']:
container_options['ports'] = []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment