Docker tutorials 1: example of creating a linux box into docker

Note:

  • We’ll call “docker machine” the environment we create inside docker, which will look like another linux box we can control. Later on, when we get familiar with the idea, we’ll also call it “the container”.
  • Red lines are run on the host machine shell, blue line are run inside the docker machine. The output (from wherever it comes) is shown in green

1) Create a linux base, update it and install apache on it

docker run --name myLinux -it ubuntu:latest bash
apt-get update
apt-get -y upgrade
ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
^D

note: the ^D exits from the shell in the docker environment, and goes back to the host shell.

2) let’s verify that the docker machine is sleeping.

We first look for active docker machines:

docker ps
CONTAINER ID       IMAGE                         COMMAND                 CREATED             STATUS                     PORTS                                          NAMES

Nothing alive is in there. We then look for “sleeping” docker machines:

docker ps -a

CONTAINER ID       IMAGE                         COMMAND                 CREATED             STATUS                     PORTS                                          NAMES
3583bb668676       ubuntu:latest                 "bash"                   23 minutes ago     Exited (0) 7 minutes ago                                                    myLinux

3a) Let us resume the “sleeping” docker machines
docker attach myLinux
ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

3b) Alternatively, if we want to get rid of the “sleeping” docker machine we would user either its id or its name:
docker rm 3583bb668676
or
docker rm ubuntu:latest

Advertisements
Posted in Docker, Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: