Skip to content

Instantly share code, notes, and snippets.

@rpivo
Last active February 21, 2021 14:11
Show Gist options
  • Save rpivo/12b11cb4f9ddf046af7b38ce6a2e0b1b to your computer and use it in GitHub Desktop.
Save rpivo/12b11cb4f9ddf046af7b38ce6a2e0b1b to your computer and use it in GitHub Desktop.
Altering a Bind Mount in a Named Docker Container From a Separate Terminal

Altering a Bind Mount in a Named Docker Container From a Separate Terminal

docker run --name bundler  -dt -v path/to/real/folder:/docker-folder amazonlinux

This first command starts a Docker container named bundler with a volume (-v) that is a bind mount between the real folder at path path/to/real/folder and the virtual Docker folder at docker-folder.

It creates the container from the amazonlinux image.

This also runs the container with the -d and the -t flags, which means that the container is running in detached mode (-d), and also with an attached TTY (-t), so it will accept commands that you give it.

docker exec -d bundler touch /bind-folder/newFile

This command executes a command on a Docker container in detached mode (-d). We specify the container to be executed on as bundler. The command itself is touch /bind-folder/newFile.

docker stop bundler

Afterward, stop the container since it will indefinitely run in the background otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment