Skip to content

Instantly share code, notes, and snippets.

@willcharlton
Created August 28, 2021 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willcharlton/18e96f7efa7b57e8d762bcbacd2887f1 to your computer and use it in GitHub Desktop.
Save willcharlton/18e96f7efa7b57e8d762bcbacd2887f1 to your computer and use it in GitHub Desktop.
Correct way to share socket and other file types between Docker Containers
# create volume for sharing
docker volume create shared-volume
# start one of your containers with the new volume mounted to a directory that the two containers will share
docker \
run --rm --init \
-v shared-volume:/shared/files \
<container_name>
# start the other with the same shared volume mounted to the same filesystem path
docker \
run --rm --privileged \
-v shared-volume:/shared/files \
<other_container_name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment