Skip to content
Snippets Groups Projects
Commit f2075548 authored by Michael Marsh's avatar Michael Marsh
Browse files

added exec and logs

parent defd1263
No related branches found
No related tags found
No related merge requests found
...@@ -239,3 +239,43 @@ Here are some useful options you might want to use: ...@@ -239,3 +239,43 @@ Here are some useful options you might want to use:
| -h | <hostname> | set the container's hostname | | -h | <hostname> | set the container's hostname |
| -p | <hport>:<cport> | map host's <hport> to container's <cport> | | -p | <hport>:<cport> | map host's <hport> to container's <cport> |
| -v | <hdir>:<cdir> | mount host's <hdir> on <cdir> | | -v | <hdir>:<cdir> | mount host's <hdir> on <cdir> |
Executing Commands in a Running Container
=========================================
Sometimes you need to examine what's going on inside a container. That's
where the *exec* command can come in handy. It's a lot like *run* but for
a container, rather than an image. Here's a common thing you might want to
do:
docker run --name=svc_instance my_service:latest
docker exec -ti svc_instance /bin/bash
What this does is to first start a container using the latest version of
the image my_service, and name the container svc_instance, and then to
execute an interactive bash shell on that container. You don't have to exec an
interactive command, though. There may be times when you want to run something
like:
docker exec svc_instance touch /var/cache/magic_file
in order to change the behavior of a running process. As with the other commands
we've looked at, "docker exec" is now an alias for "docker container exec".
Getting Process Output
======================
Many processes send their output to STDOUT or STDERR. Since there's no TTY
available to the process in a container, this output would generally be lost.
Docker saves this output for you, however, and you can retrieve these by
running
docker logs <container>
docker container logs <container>
The first command is now an alias for the second command. There are a number
of options, such as "--since" to limit the timeframe of the logs returned,
"-f" to continue to follow the logs rather than just dumping their current
contents and exiting, and "-t" to show timestamps at the beginnings of lines.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment