Basile Beldame
Basile Beldame

Reputation: 430

What are the differences between sharing a dockerfile on git and sharing a docker container?

When you create a private container on Docker, it seems to me that there are two viable options :

1 - create a private container

2 - sharing the dockerfile on a private git repository.

I'm not sure about which approach I have to chose depending on my usage, (maybe both ?), so I wanted to know if someone is interested about sharing his experience with the subject.

Upvotes: 3

Views: 138

Answers (2)

mandark
mandark

Reputation: 782

Both are effectively the same thing

A rough analogy would be saying:

  • Should I share my source code? or
  • Should I share the compiled executable?

You can choose anything.. but if the end user isn't interested in modifying the source, you might as well make it convenient for them and just share the compiled executable.

Same goes for the dockerfile or the image created using the dockerfile.

Upvotes: 3

Scott Stensland
Scott Stensland

Reputation: 28305

A Dockerfile is use to create a docker image by issuing

docker build --tag xxx .

Notice it ends with . to pickup the Dockerfile from the current dir (you can also give the path to a Dockerfile ) ... Now you can push that image to a repository for later use or to be shared. Keep in mind nothing is executing at this point ... you have just created an image which is just a chunk of code ... Sometime later you decide to launch an app using that image by doing

docker run -d -P --name cool-container-name  image-name

Above creates a container called cool-container-name which is an instantiation of the docker image ... the container is executing the code as outlined in your Dockerfile

So now its clear we can share either a Dockerfile or an image, however since a container is a chunk of executing code its not what gets shared

Upvotes: 1

Related Questions