Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
docker-tutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Alan Marsh
docker-tutorial
Commits
f2075548
Commit
f2075548
authored
7 years ago
by
Michael Marsh
Browse files
Options
Downloads
Patches
Plain Diff
added exec and logs
parent
defd1263
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README
+40
-0
40 additions, 0 deletions
README
with
40 additions
and
0 deletions
README
+
40
−
0
View file @
f2075548
...
@@ -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.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment