-2

Question 1: I have created a MERN stack application and successfully containerize and push image on Dockerhub. My friend wants to access my code so he takes a pull from DockerHub but how he can be able to see my code?

Question 2: If he is not able to see the code, how can he change the code in the workplace ?

Question 3: If an image is only used to store the setup configuration so after run the image file in his machine and run the code then how Docker put the impact on the versions if user did not run the project in the same container?

halfer
  • 19,824
  • 17
  • 99
  • 186
Deepika vijay
  • 217
  • 1
  • 2
  • 7
  • I don't understand the 3rd part of your question. – zero298 Jun 05 '20 at 21:13
  • 3
    Dockerhub shouldn't be your source control for sharing code. Put your app code, along with your Dockerfile, in Github or something and make modifications there. – dfundako Jun 05 '20 at 21:15
  • Following on from your comment elsewhere ("No I don't have a Dockerfile in my Git repo"), you need to put your Dockerfile in your repo and commit it. Your friend needs this to build his own images. It is an artefact that can be edited by all engineers with write access to the repo. – halfer Jun 06 '20 at 20:09

4 Answers4

1

You aren't exactly sharing "code" with docker, you're sharing an image that can be run. It's the difference between sharing source code and a compiled executable.

If you want it to be changable, you have to make it configurable through environment variables or arguments that are enumerated in the Dockerfile with ENV declarations that can be overridden by image consumers with docker run --env <key>=<value>.

zero298
  • 25,467
  • 10
  • 75
  • 100
1

It seems you are quite new in programming. The usual way is to create a source code repository. There are several tools. Git is the most popular one. There are tons of free places to host your code so you and your friend can access the code like Github, Gitlab, or BitBucket. In Github, you can create a private repository for free.

Then you as a part of the code you should include your .dockerfile. There are tons of places on the Internet where you can find examples of how to create and edit a .dockerfile and then your friend can build the docker solution with docker build -t [name of the app]. A good start would be in the Docker docs

Juanjo
  • 670
  • 7
  • 17
  • Hello @Junanjo ok i admit i push my code on GitHub and he took pull and i deploy image also on docker hub then my friend will take pull from both of place then next step what he need to done ? – Deepika vijay Jun 06 '20 at 07:36
0

What you are asking for , it's Git or you can find another replacement also such as Bit Bucket ... etc , if you want to share your code with your friend globally or inside the company you can use Git (Private or Public Repo depends on what you want), But for docker part it's developed to create, deploy, and run applications much faster.

Osamazx
  • 471
  • 1
  • 5
  • 12
0

I think I better understood your situation now. So please let me know if this new part answer your questions:

Question 1: You don't containerized YOUR MERN code. Your image contains commands(layers) that will build your code (you code will be copied from your computer or cloned from git repos).

Question 2:

first one also answer this.

Question 3: Your versions, don't depend from docker , but from git repository because NEVER was in your IMAGE you deploy to dockerhub. When you "docker run" a container with your IMAGE, then your code will be there, because of the COPY , ADD or VOLUMES command in your image (layers).

MikZuit
  • 684
  • 5
  • 17
  • Hello @MikZuit i am not getting it well. If image is containsn only configuration so HOw my friend use the same configuration and if he take pull the image and he will take pull from github then what process now he need to follow ? – Deepika vijay Jun 06 '20 at 07:33
  • Show what you have in your docker image, which one is your image in dockerhub? (its already public for example are you one of those https://hub.docker.com/search?q=deepika&type=image ? . when you say "I have created a MERN stack application and successfully containerize and push image on Dockerhub" it means succesfully put my code in an IMAGE and push it, at least is what I understood, that's not a good practice. – MikZuit Jun 06 '20 at 08:12
  • So please suggest me that i have developed a MERN stack application then what use of DOCKER in this ? – Deepika vijay Jun 06 '20 at 08:18
  • I suggest and Docker too , you should use DOCKER to pack what your app (MERN stack you say, not your code) need in build process, development or production. I will update my answer with tuts i think you should understand first – MikZuit Jun 06 '20 at 08:35
  • Do you have the Dockerfile in your git repository? if so, you dont need to push it to dockerhub. – MikZuit Jun 06 '20 at 08:46
  • no i don't have dockerfile in my GIT repo – Deepika vijay Jun 06 '20 at 09:04
  • I have added a new part in the begining of my answer , let me know if that helps – MikZuit Jun 06 '20 at 09:25
  • i know this very well but my question is only this that My friend take the latest pulll from GITHUB and pull image from Docker HUB. Now what will be the next step he need to perform next ? – Deepika vijay Jun 06 '20 at 10:02
  • Depens on what you have written in your Dockerfile you don't want to share. But usually if you named your image "myimage:1.0" he should just need to "docker run --name my-container myimage:1.0 /bin/sh" or "docker run --name my-container myimage:1.0 npm start" ...again depends on your dockerfile. – MikZuit Jun 06 '20 at 10:14
  • Hey MikZuit here you can find my files and description then suggest me after take pulling from docker hub what my friend needs to do. https://stackoverflow.com/q/62221963/5699811 – Deepika vijay Jun 06 '20 at 10:48