sharing docker image without docker hub or any such service - docker

I am new to docker, I was wondering how can I share my docker image with others without posting it on docker hub or any thing?
Is there any way to share image with others and later they can build the same image and run the dockerised application in their pc?

some solutions
you can give the source code and the dockerfile to someone, he will be able to build the image himself.
you can build it yourself , host the image on a private registry. really easy : https://docs.docker.com/registry/deploying/
use "docker save" to export an image as a tar file and later "docker load" it.
https://docs.docker.com/engine/reference/commandline/save/

You can use
$docker export <container_name> <tar_filename.tar>
Share the tar file
The person with whom the tar file has been shared can create container by
$docker import <tar_filename.tar>
Make sure that underlying Docker version is same to avoid unnecessary compatibility problems

Related

Some questions on Docker basics?

I'm new to docker.Most of the tutorials on docker cover the same thing.I'm afraid I'm just ending up with piles of questions,and no answers really. I've come here after my fair share of Googling, kindly help me out with these basic questions.
When we install a docker,where it gets installed? Is it in our computer in local or does it happen in cloud?
Where does containers get pulled into?I there a way I can see what is inside the container?(I'm using Ubuntu 18.04)
When we pull an image.Docker image or clone a repository from
Git.where does this data get is stored?
Looks like you are confused after reading to many documents. Let me try to put this in simple words. Hope this will help.
When we install a docker,where it gets installed? Is it in our
computer in local or does it happen in cloud?
We install the docker on VM be it you on-prem VM or cloud. You can install the docker on your laptop as well.
Where does containers get pulled into?I there a way I can see what is
inside the container?(I'm using Ubuntu 18.04)
This question can be treated as lack of terminology awareness. We don't pull the container. We pull the image and run the container using that.
Quick terminology summary
Container-> Containers allow you to easily package an application's code, configurations, and dependencies into a template called an image.
Dockerfile-> Here you mention your commands or infrastructure blueprint.
Image -> Image gets derived from Dockerfile. You use image to create and run the container.
Yes, you can log inside the container. Use below command
docker exec -it <container-id> /bin/bash
When we pull an image.Docker image or clone a repository from
Git.where does this data get is stored?
You can pull the opensource image from Docker-hub
When you clone the git project which is docerized, you can look for Dockerfile in that project and create the your own image by build it.
docker build -t <youimagenae:tag> .
When you build or pull the image it get store in to your local.
user docker images command
Refer the below cheat-sheet for more commands to play with docker.
The docker daemon gets installed on your local machine and everything you do with the docker cli gets executed on your local machine and containers.
(not sure about the 1st part of your question). You can easily access your docker containers by docker exec -it <container name> /bin/bash for that you will need to have the container running. Check running containers with docker ps
(again I do not entirely understand your question) The images that you pull get stored on your local machine as well. You can see all the images present on your machine with docker images
Let me know if it was helpful and if you need any futher information.

Docker: How to get docker image to GitHub

I built a docker image like this:
sudo docker image build -t docker_image_gotk3 .
If I execute
sudo docker images I can see the line:
REPOSITORY TAG IMAGE ID CREATED SIZE
docker_image_gotk3 latest c13f7fcdb11d 14 minutes ago 20.4MB
I searched the complete file system and I didn't find a single file named docker_image_gotk3. How do I actually get it?
You have to export the docker image to push GitHub.
docker save -o docker_image_gotk3.tar docker_image_gotk3
ls -sh docker_image_gotk3.tar
20.4M docker_image_gotk3.tar
Github doesn't appear to have a Docker registry service as of now.
Maybe you could try tracking your image in Docker Hub as an alternative to what Tibi02 proposes?
Just create an account at https://hub.docker.com/ if you don't have one already, and do the following:
docker login in your terminal to authenticate in Docker Hub
docker image push your_username/docker_image_gotk3:latest to upload your image to the registry
Then you should be able to see it at https://cloud.docker.com/repository/docker/you_username/docker_image_gotk3, and download your image with docker image pull your_username/docker_image_gotk3:latest
Hope this helps!

Is there a way to download docker hub images whitout "docker pull" for a machine with out Internet access?

I want to download some images for a computer that has not internet.
My computer that have internet has NO DOCKER installed (old kernel) so it is not possible to use docker command to pull, save and export it to the other machine.
I'm looking for a way to download a docker image (like via wget, ...) and use it on my computer without Internet.
Yes that's possible. Docker has the features save and load.
Run this command on your machine with the image you want to copy to the other computer:
docker save myimage > myimage.tar
To load the image again run:
docker load < myimage.tar
If you don't have access to a machine supporting docker in any way what you can do is create a repository on quay.io with a dockerfile like
FROM myimage
...
quay actually allows to download images from the web panel whereas docker hub/store does not afaik.

Docker: Find dockerfile of images

I'm interested in how some images are build, and would like to know where docker saves the images/Dockerfile. I'm using a Mac and the docker version is 1.9.0. On google I see a lot about boot2docker but I don't seem to have that executable. I simply click the Docker Quickstart terminal and I can do
$> docker run dockerinaction/hello_world
I noticed that for the hello-word image I can find the dockerfile on hub.docker.com, but for onedio/base-node5 I can't. Is it possible to find the Dockerfile for base-node5 on hub.docker.com ?
Use dockerfile-from-images from centurylinkabs, that will create the Dockerfile, see https://github.com/centurylinklabs/dockerfile-from-image
You can get a lot of that info from the Docker History command
docker history onedio/base-node5

How to move docker installation to another machine?

I know about /var/lib/docker but is mounting this directory on another machine enough to recover the docker functionality on the original machine? I tried this between different CoreOS instances but when issued docker image the images did not appear even though they were in the /var/lib/docker directory. Am I missing some other data that should be transferred?
The end goal is to have a portable 'repo' of images that I can build on from any machine.
related Where are Docker images stored on the host machine?
docker export, scp from machine A to machine B, and docker import should work well for you.
I think in order for you to transfer docker images like this they have first be compressed as tar's.
for the above query,if i am not wrong, you want to transfer images(all images) to a remote machine.
An easy way for this approach is creating a registry on the second machine(say machine B) and push all images from the main machine(machine A).
However i suspect that there is some permission problem with the local mount point which you are referring.I suggest you to first check out with chmod 777 command on the localmount point.Then if it works you can give access with restricted permissions.
Similarly, I have not tried mounting on other machine /var/lib/docker but incase if it had to work you should give permission and it should be owned by docker group.
Let us know if it is the permission issue that you faced.
good luck
So in my solution I use both a private docker registry and a 'shared' /var/lib/docker that I mount between my (ephemeral) instances/build machines. I intend to use the registry to distribute images to machines that wont be building. Sharing the docker dir helps with keeping the build time down. I have the following steps for each dockerfile.
docker pull $REGISTRY_HOST/$name
docker build -t $name $itsdir
echo loading into registry \
$REGISTRY_HOST/$name
#assuming repos in 'root' ( library/ )
docker rmi $REGISTRY_HOST/$name
docker tag $name $REGISTRY_HOST/$name
docker push $REGISTRY_HOST/$name
docker rmi $REGISTRY_HOST/$name
I think this works.

Resources