You can get a shell prompt inside an existing container this way Local

You can get a shell prompt inside an existing

This preview shows page 205 - 215 out of 350 pages.

You can get a shell prompt inside an existing container this way. Local Development Workflow with Docker Docker Fundamentals a2622f1 205 © 2015 Docker Inc
Image of page 205
docker exec example $ # You can run ruby commands in the area the app is running and more! $ docker exec -it <yourContainerId> bash [email protected]:/opt/namer# irb irb(main):001:0> [0, 1, 2, 3, 4].map {|x| x ** 2}.compact => [0, 1, 4, 9, 16] irb(main):002:0> exit Local Development Workflow with Docker Docker Fundamentals a2622f1 206 © 2015 Docker Inc
Image of page 206
Stopping the container Now that we're done let's stop our container. $ docker stop <yourContainerID> And remove it. $ docker rm <yourContainerID> Local Development Workflow with Docker Docker Fundamentals a2622f1 207 © 2015 Docker Inc
Image of page 207
Section summary We've learned how to: Share code between container and host. Set our working directory. Use a simple local development workflow. Local Development Workflow with Docker Docker Fundamentals a2622f1 208 © 2015 Docker Inc
Image of page 208
Working with Volumes Working with Volumes Docker Fundamentals a2622f1 209 © 2015 Docker Inc
Image of page 209
Lesson 16: Working with Volumes Objectives At the end of this lesson, you will be able to: Create containers holding volumes. Share volumes across containers. Share a host directory with one or many containers. Working with Volumes Docker Fundamentals a2622f1 210 © 2015 Docker Inc
Image of page 210
Working with Volumes Docker volumes can be used to achieve many things, including: Bypassing the copy-on-write system to obtain native disk I/O performance. Bypassing copy-on-write to leave some files out of docker commit . Sharing a directory between multiple containers. Sharing a directory between the host and a container. Sharing a single file between the host and a container. Working with Volumes Docker Fundamentals a2622f1 211 © 2015 Docker Inc
Image of page 211
Volumes are special directories in a container Volumes can be declared in two different ways. Within a Dockerfile , with a VOLUME instruction. VOLUME /var/lib/postgresql On the command-line, with the -v flag for docker run . $ docker run -d -v /var/lib/postgresql \ training/postgresql In both cases, /var/lib/postgresql (inside the container) will be a volume. Working with Volumes Docker Fundamentals a2622f1 212 © 2015 Docker Inc
Image of page 212
Volumes bypass the copy-on-write system Volumes act as passthroughs to the host filesystem. The I/O performance on a volume is exactly the same as I/O performance on the Docker host. When you docker commit , the content of volumes is not brought into the resulting image. If a RUN instruction in a Dockerfile changes the content of a volume, those changes are not recorded neither. Working with Volumes Docker Fundamentals a2622f1 213 © 2015 Docker Inc
Image of page 213
Volumes can be shared across containers You can start a container with exactly the same volumes as another one.
Image of page 214
Image of page 215

You've reached the end of your free preview.

Want to read all 350 pages?

  • Fall '19

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture