mirror of
https://github.com/wsargent/docker-cheat-sheet.git
synced 2025-12-17 23:50:13 +01:00
Add section on nsenter, line about vagrant.
This commit is contained in:
parent
dab036a87d
commit
39844512c8
1 changed files with 20 additions and 11 deletions
17
README.md
17
README.md
|
|
@ -74,7 +74,7 @@ Then start up a container:
|
|||
sudo docker run -i -t ubuntu /bin/bash
|
||||
```
|
||||
|
||||
That's it, you have a running Docker container.
|
||||
That's it, you have a running Docker container. Also note that Vagrant 1.6 has Docker [supported as a built-in provisioner](https://docs.vagrantup.com/v2/docker/index.html) which can help you when configuring images.
|
||||
|
||||
I use [Oh My Zsh](https://github.com/robbyrussell/oh-my-zsh) with the [Docker plugin](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins#docker) for autocompletion of docker commands. YMMV.
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ Some common misconceptions it's worth correcting:
|
|||
* [`docker attach`](http://docs.docker.io/reference/commandline/cli/#attach) will connect to a running container.
|
||||
* [`docker wait`](http://docs.docker.io/reference/commandline/cli/#wait) blocks until container stops.
|
||||
|
||||
If you want to run and then interact with a container, `docker start` then `docker attach` to get in.
|
||||
If you want to run and then interact with a container, `docker start` then `docker attach` to get in (or, as of 0.9, `nsenter`).
|
||||
|
||||
If you want a transient container, `docker run -rm` will remove the container after it stops.
|
||||
|
||||
|
|
@ -129,6 +129,17 @@ There doesn't seem to be a way to use docker directly to import files into a con
|
|||
* [`docker cp`](http://docs.docker.io/reference/commandline/cli/#cp) copies files or folders out of a container's filesystem.
|
||||
* [`docker export`](http://docs.docker.io/reference/commandline/cli/#export) turns container filesystem into tarball.
|
||||
|
||||
### Entering a Docker Container
|
||||
|
||||
The "official" way to enter a docker container while it's running is to use `nsenter`, which uses [libcontainer under the hood](http://jpetazzo.github.io/2014/03/23/lxc-attach-nsinit-nsenter-docker-0-9/). Using an `sshd` daemon is [considered evil](http://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil/).
|
||||
|
||||
Unfortunately, nsenter requires some configuration and installation. Here's how to do it on MacOS:
|
||||
|
||||
* [How to enter a Docker container](https://blog.codecentric.de/en/2014/07/enter-docker-container/)
|
||||
* [Docker debug with nsenter on boot2docker](http://blog.sequenceiq.com/blog/2014/07/05/docker-debug-with-nsenter-on-boot2docker/)
|
||||
|
||||
I can't quite figure out why you'd want to use `nsenter` over `docker attach`. This would be a good place for an editor to submit a pull request.
|
||||
|
||||
## Images
|
||||
|
||||
Images are just [templates for docker containers](http://docker.readthedocs.org/reference/terms/image/).
|
||||
|
|
@ -341,5 +352,3 @@ docker rm `docker ps -a -q`
|
|||
```
|
||||
docker images -viz | dot -Tpng -o docker.png
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue