docker interview questions
Top docker frequently asked interview questions
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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 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)
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)