Created
January 27, 2015 03:53
-
-
Save dnephin/083a1052b8293a5b46a4 to your computer and use it in GitHub Desktop.
Docker volumes set using bind at start time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM busybox:latest | |
RUN mkdir /data | |
RUN touch /data/file | |
VOLUME /data | |
CMD echo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import docker | |
def run(): | |
client = docker.Client() | |
client.build('.', tag='example_volumes', stream=False) | |
container = client.create_container('example_volumes') | |
client.start(container) | |
client.wait(container) | |
volumes = client.inspect_container(container)['Volumes'] | |
print volumes | |
# Now start another container that tries to use this volume | |
container = client.create_container('example_volumes') | |
client.start(container, binds={ | |
volumes['/data']: {'bind': '/data', 'ro': False}, | |
}) | |
client.wait(container) | |
print client.inspect_container(container)['Volumes'] | |
if __name__ == "__main__": | |
run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
virtualenv venv | |
source venv/bin/activate | |
pip install docker-py | |
python repo.py | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment