EzDevInfo.com

docker interview questions

Top docker frequently asked interview questions

How do you list containers in Docker.io?

There's a command to list images, docker images, but there doesn't seem to be a corresponding docker containers.

Other than becoming root and looking into /var/lib/docker there doesn't seem a way to do that. Am I missing something? Is that something one isn't supposed to do?


Source: (StackOverflow)

Is it possible to start a shell session in a running container (without ssh)

I was naively expecting this command to run a bash shell in a running container :

docker run "id of running container" /bin/bash

it looks like it's not possible, I get the error :

2013/07/27 20:00:24 Internal server error: 404 trying to fetch remote history for 27d757283842

So, if I want to run bash shell in a running container (ex. for diagnosis purposes)

do I have to run an SSH server in it and loggin via ssh ?


Source: (StackOverflow)

Advertisements

How is Docker different from a normal virtual machine?

I keep rereading the Docker documentation to try to understand the difference between Docker and a full VM. How does it manage to provide a full filesystem, isolated networking environment, etc. without being as heavy?

Why is deploying software to a docker image (if that's the right term) easier than simply deploying to a consistent production environment?


Source: (StackOverflow)

How to scale Docker containers in production

So I recently discovered this awesome tool, and it says

Docker is an open-source project to easily create lightweight, portable, self-sufficient containers from any application. The same container that a developer builds and tests on a laptop can run at scale, in production, on VMs, bare metal, OpenStack clusters, public clouds and more.

Let's say I have a docker image which runs Nginx and a website connects to external database. How do I scale the container in production?


Source: (StackOverflow)

Exposing a Port on a Live Docker Container

I'm trying to create a Docker container that acts like a full-on virtual machine. I know I can use the EXPOSE instruction inside a Dockerfile to expose a port, and I can use the -p flag with docker run to assign ports, but once a container is actually running, is there any command to open/map additional ports live?

For example, let's say I have a docker container that is running sshd. Someone else using the container ssh's in and installs httpd. Is there any way to expose port 80 on the container and map it to port 8080 on the host, so that people can visit the web server running in the container, without restarting it?


Source: (StackOverflow)

Docker - copy file from container to host

I'm thinking of using docker to build my dependencies on a CI server, to that I don't have to install all the runtimes and libraries on the agents themselves. To achieve this I would need to copy the build artefacts that are built inside the container back into the host.

Is that possible?


Source: (StackOverflow)

Should I use Vagrant or Docker for creating an isolated environment?

I use Ubuntu for development and deployment, and have a need for creating an isolated env.

I am considering either Vagrant or Docker for this purpose? Can anyone help me with the pros and cons, or a comparison of both of these solutions?


Source: (StackOverflow)

Where are docker images stored on the host machine?

I managed to find the containers under directory /var/lib/docker/containers, but can't find the images.

Can somebody explain the directories and files under /var/lib/docker?


Source: (StackOverflow)

Getting a docker container's ip address from the host

Is there a command I can run to get the container's ip address right from the host after a new container is created? Basically, once docker creates the container, I want to roll my own code deployment and container configuration scripts.


Source: (StackOverflow)

can you run GUI apps in a docker container?

How can you run GUI apps in a docker container?

Are there any images that set up vncserver or something so that you can - for example - add an extra speedbump sandbox around say Firefox?


Source: (StackOverflow)

Docker how to change repository name or rename image?

I'm trying to change repository name of the image:

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
server              latest              d583c3ac45fd        26 minutes ago      685.5 MB

Hence I want to change the name server to something like myname/server:

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
myname/server       latest              d583c3ac45fd        26 minutes ago      685.5 MB

How can I do this?


Source: (StackOverflow)

How to share my Docker-Image without using the Docker-Hub?

I'm wondering where Docker's images are exactly stored to in my local host machine. Can I share my Docker-Image without using the Docker-Hub or a Dockerfile but the 'real' Docker-Image? And what is exactly happing when I 'push' my Docker-Image to Docker-Hub?


Source: (StackOverflow)

How to deal with persistent storage (e.g. databases) in docker

How do you guys deal with persistent storage for your docker containers? I am currently using this approach: build the image, e.g. for Postgres, and then start the container with

docker run --volumes-from c0dbc34fd631 -d app_name/postgres

IMHO, that has the drawback, that I must not ever (by accident) delete container "c0dbc34fd631".

Another idea would be to mount host volumes "-v" into the container, however, the userid within the container does not necessarily match the userid from the host, and then permissions might be messed up.

edit: update "I cannot ever delete" to "I must not ever delete"

edit: instead of "--volumes-from 'cryptic_id'" you can also use "--volumes-from my-data-container" where "my-data-container" is a name you assigned to a data-only container, e.g. "docker run -name my-data-container ..." (see accepted answer)


Source: (StackOverflow)

How to remove old Docker containers

This question is related to Should I be concerned about excess, non-running, Docker containers?.

I'm wondering how to remove old containers. The docker rm 3e552code34a lets you remove a single one, but I have lots already. docker rm --help doesn't give a selection option (like all, or by image name).

Maybe there is a directory in which these containers are stored where I can delete them easily manually?


Source: (StackOverflow)

Docker COPY vs ADD

What is the difference between the COPY and ADD commands in a Dockerfile, and when would I use one over the other?


COPY <src> <dest>

The COPY instruction will copy new files from <src> and add them to the container's filesystem at path <dest>


ADD <src> <dest>

The ADD instruction will copy new files from <src> and add them to the container's filesystem at path <dest>.


Source: (StackOverflow)