Solved: docker – error during connect

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.

Solved: How to copy paste in Docker Quickstart Terminal

If you want to copy/paste the contents on Docker Quickstart Terminal using mouse follow these steps.

  • Open the Docker Quickstart Terminal as an Administrator.
  • At the top of terminal right Click on the Blue Whale icon and select “Defaults”.
  • In the “Options” tab of new window check the QuickEdit Mode(refer image below) and click OK.

t

  • Now with mouse left click you can select the content and paste with right click.

Solved: How to cap or limit memory usage of a docker container

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).

version: '3'
services:
 redis:
 image: redis:alpine
 deploy:
 resources:
 limits:
 cpus: '0.50'
 memory: 50M
 reservations:
 cpus: '0.25'
 memory: 20M

Hope this post is helpful to you. Do let me know if you have any query.

Solved: How to create an image of a docker container.

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 .