Giter Site home page Giter Site logo

docker-enter-demo's Introduction

Docker Demo

This demo gives an introduction on how to enter running Docker containers. Please see my blog post for details.

The demo shows 4 options to enter a running container:

  1. ssh
  2. nsenter
  3. nsinit
  4. lxc-attach

For each demo exists a directory with at least 2 scripts install.sh and docker-enter.sh. The install script installs all necessary dependencies and the docker-enter script will connect you with the running test container. For more details see chapter 2 Run Demo

Feel free to contact me for any questions or comments.

Prerequisites

Docker builds upon Linux Containers (LXC) and thus only runs on Linux. In order to allow you to also play with Docker on non-Linux machines, there are two ways to run this demo, i.e., inside a Vagrant Box or directly on Linux. Please see the respective subsections below.

Vagrant Box

If you decide to run the demo inside a Vagrant box, please install Vagrant accordingly. The Vagrantfile provided requires Vagrant version 1.4.0 or higher, because starting from that version Docker can be automatically installed. As provider, VirtualBox is assumed. Once Vagrant is installed, just run

vagrant up; vagrant ssh

cd /vagrant

in the root directory. Then follow the same instructions as for native Linux.

Native Linux

If you decide to run the demo on a native Linux, please install Docker according to your distribution. There are How-Tos for many different distributions in the Docker documentation.

Running the Demo

1. Build test container

In the first step we need a test container that we can enter. In the docker directory exists a Dockerfile that builds an ubuntu 13.04 image. When a container of that image is started a sshd process will be started via supervisord. To build and start the test container, just run

cd /vagrant/docker

./run.sh

Now you should see the running container named supervisord via

docker ps

2. Run Demo

ssh

In order to enter the test container via ssh, just run

cd /vagrant/ssh

./install.sh

./docker-enter.sh

nsenter

In order to enter the test container via nsenter, just run

cd /vagrant/nsenter

./install.sh

sudo su -

cd /vagrant/nsenter

./docker-enter.sh

nsinit

In order to enter the test container via nsinit, just run

sudo su -

cd /vagrant/nsinit

./install.sh

Now you have to log out and log in as root again because we set some environment variables for go-lang. Afterwards just run

./docker-enter.sh

lxc-attach

In order to enter the test container via lxc-attach, just run

cd /vagrant/lxc-attach

./install.sh

sudo su -

./start-docker-lxc.sh

./docker-enter.sh

If you want to run the docker daemon in default mode again, just run

./start-docker-default.sh

docker-enter-demo's People

Contributors

aberresch avatar berresch avatar

Watchers

James Cloos avatar Ajayi Olabode avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.