sagu@sagu-pc MINGW64 ~
$ docker image ls
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.29/images/json: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
sagu@sagu-pc MINGW64 ~
If you are getting above error while running the docker commands in Docker Quickstart Terminal then you can have one of the listed problem.
The docker deamon is not running.
The docker host machine itself is down.
Required configuration file is missing.
First check that the host machine is up and the configuration file is present at its location. Once you are sure both the above things are ok, in that case easiest way to get rid of this issue is to open the Docker Quickstart Terminal by selecting “Run as Administrator” . It will take some time to start but let it complete and you should be back in business soon.
Once you are done with docker installation let’s move ahead.
In the windows command prompt or in “Docker Quickstart Terminal” execute below command. By default it will pull the latest image of ubuntu container available in repository.
C:\CloudVedas>docker run ubuntu
If you need specific version of Ubuntu you can mention the version name in command. Like below we are pulling Ubuntu 14.04 version. You can check all the available versions here .
Now let’s see the image we have downloaded .
Let’s create a container with that image using the image id. Here we are using -d option so that the container runs in detached mode and we can login to it.
List the running containers using “docker container ls”
We can see our container is created 5 minutes ago and is up. You can also identify the container using the container id. Note that the container ID is same as the first 12 digits of the string we got when we executed docker run in last step.
Let’s get inside our container and check it.
Once you are inside the Ubuntu container you can explore it. Let’s check the OS version.
In this post we will see how we can cap or restrict the maximum amount of memory the container can use.
Let’s first see the current usage of container id ec6ed4af7c34 with “docker stats”.
docker stats ec6ed4af7c34
In the below image we can see the current limit of the container is 300MiB
Now let’s change this limit to 200MiB of a running container.
docker container update -m 200m ec6ed4af7c34
Now when we look at “docker stats” we can see in the image below the new limit on the container.
If you want to set the memory limit at the time of launching the container itself do it as
docker run -exec -it -m 200m image-name /bin/bash
Compose file version 3
If you want to restrict the usage from the compose file itself you can follow below example, the redis service is constrained to use no more than 50M of memory and 0.50 (50%) of available processing time (CPU), and has 20M of memory and 0.25 CPU time reserved (as always available to it).
So you have completed all the installation on a docker container and now you want to keep it as golden image.
Golden images are useful when you want to create more containers with same configuration. This also ensure that when you ship an image from Dev to UAT or Prod it will be exactly same as it was when you tested it.
This also avoid problems during release.
So how you create an image from a running container.
Let’s have a look. We have a running container with ID d885f4ea3cff.
docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d885f4ea3cff d355ed3537e9 "/bin/bash" 25 hours ago Up 53 minutes ansible
We already did all the installations in it. So we will commit and create an image “ansible-base” .
docker commit d885f4ea3cff ansible-base
Now if you look at the image list you should see the new image.
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
ansible-base latest 1fbdr6f81e4c 39 minutes ago 159 MB
You can create a new container with this image
docker run -t -i -d 1fbdr6f81e4c /bin/bash
Notice the “-d” above it will run the container in detached mode so even if you logout of the container it will remain up.
List the containers that are running
docker container ls
Login to the container with container id d985be2f2c3e you created now.
docker exec -it d985be2f2c3e bash
If you want to rename the new container check this post .