What is The Docker Ops Perspective?

 What is The Docker Ops Perspective? 

What is The Docker Ops Perspective?

The Ops Side will include:

  • Download an image
  • Start a new container
  • Log in to the new container
  • Run a command inside of it
  • And then destroy it.

We get two major components when we install Docker.

  1. the Docker client
  2. the Docker daemon

The daemon gears the Docker Remote API. The client debates to the daemon through a local IPC/Unix socket at /var/run/docker.sock in a default Linux installation. This occurs on Windows by means of a named pipe at npipe:////./pipe/docker_engine. We may test that the client and daemon are running and can talk to each other with the docker version command.

$ docker version 

Client:

Version: 17.05.0-ce

API version: 1.29

Go version: go1.7.5

Git commit: 89658be

Built: Thu May 4 22:10:54 2017

OS/Arch: linux/amd64

Server:

Version: 17.05.0-ce

API version: 1.29 (minimum version 1.12)

Go version: go1.7.5

Git commit: 89658be

Built: Thu May 4 22:10:54 2017

OS/Arch: linux/amd64

Experimental: false

We should be good to go if we get a response back from the Client and Server components. Try the command again with sudo in front of it: sudo docker version, if we are using Linux and get an error response from the Servercomponent. We will require adding our user account to the local docker group, if it works with sudo.

Images

An object that contains an OS filesystem and an application is known as Docker image. It’s like a virtual machine template if we work in operations. An image is effectively a stopped container in the Docker world. We may think of an image as a class if we are working as developer. Run the docker image ls command on our Docker host.

$ docker image ls

REPOSITORY        TAG       IMAGE ID        CREATED               SIZE

It would have no images if we are working from a freshly installed Docker host and will look similar the output above. Receiving images onto our Docker host is called “pulling”. Pull the Ubuntu latest if we are following along with Linux. Pull the microsoft/powershell:nanoserver image, if we are following along on Windows. An image holds sufficient of an operating system (OS), in addition to all the code and dependencies to run whatever application it’s designed for.

Containers

We may use the docker container run command to launch a container from it.

For Linux:

$ docker container run -it ubuntu:latest /bin/bash

root@6dc20d508db0:/#

For Windows:

> docker container run -it microsoft/powershell:nanoserver PowerShell.exe

Windows PowerShell

Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:>

We should note from above that the shell prompt has changed in each instance. This is due to our shell is now attached to the shell of the new container – Exactly we are inside of the new container! The docker container run tells the Docker daemon to start a new container. The -it flags express the daemon to create the container interactive and to attach our current terminal to the shell of the container. Next, the command tells Docker that we want the container to be based on the Ubuntu: latest image or the Microsoft/PowerShell: Nano server image if we’re following along with Windows. Lastly, we tell Docker which process we want to run inside of the container. We’re running a Bash shell for the Linux example, for the Windows containers were running PowerShell. Run a ps command from inside of the container to list all running processes.

Please note that how many more processes are running on our Docker host compared to the containers we ran. We pressed Ctrl-PQ to exit from the container in a previous step. Doing this from inside of a container will exit us from the container without killing it. We may understand all running containers on our system using the docker container ls command.

$ docker container ls

CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES

e2b69eeb55cb ubuntu:latest “/bin/bash” 6 mins Up 6 min vigilant_borg

The yield above displays a single running container. We created earlier this container. The occurrence of our container in this output shows that it’s quiet running. We can also realize that it was created 6 minutes ago and has been running for 6 minutes.

Attaching to running containers

We may assign our shell to running containers with the docker container exec command. Let’s connect back to it as the container from the previous steps is still running.

Linux example:

This instance places a container called vigilant_borg. Remember to substitute vigilant_borg with the name or ID of the container running on our Docker host as the name of our container will be different.

$ docker container exec -it vigilant_borg bash

root@e2b69eeb55cb:/#

Windows example:

This instance mentions a container called pensive_hamilton .Remember to substitute pensive_hamilton with the name or ID of the container running on our Docker host as The name of our container will be different.

> docker container exec -it pensive_hamilton PowerShell.exe

Windows PowerShell

Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:>

Please note here that our shell prompt has changed again. We are back inside the container. The format of the docker container exec command is: docker container exec -options . We used the -it options to attach our shell to the container’s shell in our instance. We placed the container by name and expressed it to run the bash shell. That was PowerShell in the Windows example. We might simply have referenced the container by its ID. Exit the container again by pressing Ctrl-PQ. Our shell prompt should be back to our Docker host. Run the docker container ls command again to verify that our container is still running.

$ docker container ls

CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES

E3b78eeb88cb ubuntu: latest “/bin/bash” 9 mins Up 9 min vigilant_borg

Now stop the container and destroy it using the docker container stop and docker container rm commands. Remember to substitute the names/IDs of our own containers.

$ docker container stop vigilant_borg

vigilant_borg

$$

docker container rm vigilant_borg

vigilant_borg

Confirm that the container was successfully deleted by running another docker container ls command.

$ docker container ls

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

 

Leave a Comment