Posts

Showing posts from May, 2017

Sharing private docker images

There are situations when we need to distribute our images without docker hub. As you know docker hub is public docker registry therefore anyone can see the images uploaded. You can choose to pay for a private account, but that would still involve transferring the image to the hub and back. Sometimes we just want to copy our confidential images form one host to another. A simple way to achieve this to use: docker save imagename > imagename.tar This will take the image form your local docker repository and exports it to a tar file. One can use gzip to compress the image further. Loading the images on a different host also straightforward. docker load -i imagename.tar Docker will restore the image with its layers into the new repository.

Untag a docker image

Problem: I have more than one tag on an image in my docker repository. Solution: Docker hasn't got untag command, but if you remove the image using its tag it will untag it for you. docker rmi imagetag

Running docker without sudo

Problem: I don't want to use sudo all the time when I issue docker commands. Solution: Create a docker group: sudo groupadd docker Add your user to group: sudo gpasswd -a myuser docker Restart docker service: sudo service docker restart Login to your newgroup: newgrp docker Source https://askubuntu.com

Making changes in a running docker container

In this example I assume that you are using a tomcat contanier and a webapp deloyed in the container. Problem:  I have a webapp running in a docker container and I want to change the log level. Solution: Get a bash shell into your container. docker exec -it containerid /bin/bash Do the change that you need to do. Stop your container docker stop containerid Start your container docker start containerid This change will not get saved into the image as soon as you destory your container instance you will loose the change.

Debug a running docker container

Problem: I have a running docker container how can I peek inside? Solution: docker exec -it containerid /bin/bash This will give you a bash shell in the container.

Debug a docker container failing to run

Problem: I was building a new docker image and it failed to run every time I tryied. As you know if the container isn't running you can't peek inside. Solution:: Run bash using the image so you can poke around to find the cause. docker run -it imagename /bin/bash