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.
Error response from daemon: Error when allocating new name: Conflict. The container name "/webserver" is already in use by container 6c34a8wetwyetwy7463462d329c9601812tywetdyud76767d65f7dc7ea58d8541. You have to remove (or rename) that container to be able to reuse that name.
If you see the above error it is because a container with same name exist.