SSH Into A Container
SSH Into A Container
<command> . For example, to get a shell into your web container you might run docker-compose run
web /bin/bash
To run a series of commands, you must wrap them in a single command using a shell. For
example: docker-compose run
<name in yml> sh -c '<command 1> && <command 2> && <command 3>'
In some cases you may want to run a container that is not de ned by a docker-compose.yml
le, for example to test a new container con guration. Use docker run to start a new container
with a given image: docker run -it <image name> <command>
The docker run command accepts command line options to specify volume mounts,
environment variables, the working directory, and more.
phase2.github.io/devtools/common-tasks/ssh-into-a-container/ 1/2
Running commands, but not from a dedicated shell
12/04/2019 SSH into a container - DevTools CLI Documentation
Another concept in the Docker world is starting a container to run a single command and
allowing the container stop when the command is completed. This is great if you run
commands infrequently, or don't want to have another container constantly running. Running
your commands on containers in this fashion is also well suited for commands that don't
generate any les on the lesystem or if they do, they write those les on to volumes mounted
into the container.
The drush container de ned in the example build.yml le is a container designed speci cally
to run drush in a single working directory taking only the commands as arguments. This
approach allows us to provide a quick and easy mechanism for running any drush command,
such as sqlc , cache-rebuild , and others, in your Drupal site quick and easily.
There are also other examples of a grunt command container similar to drush and an even
more speci c command container around running a single command, drush make to build the
site from a make/dependency le.
phase2.github.io/devtools/common-tasks/ssh-into-a-container/ 2/2