Dockerfile Tutorial - Docker in Practice || Docker Tutorial 10

Dockerfile simply explained. This is a Dockerfile tutorial by example.
To deploy your application with Docker it must be packaged to it's own docker container. So, this means a docker image needs to be built from our JavaScript and Nodejs application and prepare it to be deployed on some environment. This will usually be done by an CD like Jenkins.
But in this video we will simulate what Jenkins does locally, building a docker image from our application locally.
▬▬▬▬▬▬ T I M E S T A M P S 🐳
0:00 - Intro
1:49 - What is a Dockerfile?
2:22 - How the Dockerfile commands map to the image environment
8:05 - Create the Dockerfile (Demo)
12:00 - Build an image out of the Dockerfile
15:02 - Start the Application to verify: 1) App starts successfully 2) App environment is configured correctly
19:34 - do improvement - copy only relevant files
"Docker in Practice":
Developing with Docker ► • Developing with Docker...
Docker Compose ► • Docker Compose Tutoria...
Dockerfile ► • Dockerfile Tutorial - ...
Private Repository ► • Private Repository exp...
Deploy your containerized Application ► • Deploying the containe...
You can check out my videos for the Pre-Requisites:
✅ Basic Docker Concepts: • What is a Docker Conta...
✅ Basic Commands: • 8 Basic Docker Command...
For any questions/issues/feedback, please leave me a comment and I will get back to you as soon as possible.
►► Full Docker and Kubernetes Tutorial Playlist: bit.ly/2YGeRp9
This video is the 10th of a complete series for beginners, where I explain the basic concepts and also show you demo's like deploying your containerized application. At the end of this tutorial you will fully understand Docker and Kubernetes.
💡 Only interested in Docker?
►► Complete Docker Tutorial Playlist: bit.ly/2ymJHbX
#docker #dockertutorials #devops #techworldwithnana
-------------------------------------------------------------------------------------
The complete step-by-step guide to Docker and Kubernetes will include the following content:
🐳 D O C K E R
- Container concept
- Why docker? (image vs. traditional DevOps)
- Install docker on different operating systems
- 8 basic commands you need to know
- Docker vs. Virtual Machine
- Docker in Practice: Overview of whole development process with Docker (development, continuous delivery, deployment)
- Develop an application with Docker
- Docker Compose
- Dockerfile
- Private Repository
- Deploying your containerized application
- Docker Volumes from theory to practice
✵ K U B E R N E T E S
- Main Kubernetes components (including Pod, Service, Ingress, Volumes, ConfigMap, Secrets, Deployment, StatefulSet)
- Kubernetes architecture for beginners (master, slave nodes & processes)
- Understand how does K8s REALLY work? Main Concepts of how to use K8s
- Minikube, Kubectl - set up the cluster and connect to it
- Kubectl main commands - Demo
- Configuration file (YAML) - syntax
- Kubernetes Namespaces
- Communication between the pods - basic networking concepts in Kubernetes
- K8s Deployment in practice - example application deployment (pod + service + Ingress + secret)
▬▬▬▬▬▬ Connect with me 👋 ▬▬▬▬▬▬
Join private Facebook group ► bit.ly/32UVSZP
Don't forget to subscribe ► bit.ly/3mO4jxT
DEV ► bit.ly/3h2fqiO
INSTAGRAM ► bit.ly/2F3LXYJ
TWITTER ► bit.ly/3i54PUB
LINKEDIN ► bit.ly/3hWOLVT
Legal Notice:
Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries. Docker, Inc. and other parties may also have trademark rights in other terms used herein. This video is not accredited, certified, affiliated with, nor endorsed by Docker, Inc.

Пікірлер: 163

  • @TechWorldwithNana
    @TechWorldwithNana4 жыл бұрын

    0:36- Review Diagram - Workflow 1:49 - What is a Dockerfile? 2:22 - How the Dockerfile commands map to the image environment 8:05 - Create the Dockerfile (Demo) 12:00 - Build an image out of the Dockerfile (Demo - simulating Jenkins) 15:02 - Start the Application to verify: 1) App starts successfully 2) App environment is configured correctly 19:34 - do improvement - copy only relevant files 👉🏼 For any questions/issues/feedback, please leave me a comment and I will get back to you as soon as possible. 👉🏼 Also please let me know what you want to learn about Docker & Kubernetes. Also please don't forget to subscribe and give me a thumbs up if you liked my video 🤗

  • @madhavijonnavitula9668

    @madhavijonnavitula9668

    10 ай бұрын

    Very useful video....❤from india

  • @krishnamedas5895

    @krishnamedas5895

    10 ай бұрын

    where do i get server.js file i can see it on my local machine thanks

  • @specimenhunter73
    @specimenhunter735 ай бұрын

    Probably the dockerfile tutorial with the highest "information density" I know. Thank you for the sharp and precise explanations !

  • @alexona1
    @alexona13 жыл бұрын

    Omg, I've learnt so much from your video! You explained everything in details and very clearly. This helped me create my first Dockerfile, and it works perfectly

  • @kareemakeem8602
    @kareemakeem8602 Жыл бұрын

    Good morning, I'm here to really commend and appreciate your good works. I do really enjoyed your series of videos on docker and Kubernetes. They are very inspiring, full of contents and simplified. Thanks

  • @Tiejocky
    @Tiejocky3 жыл бұрын

    Nicely done video. Its clear and to the point. Thank you for your efforts and sharing your knowledge with the rest of us.

  • @MuhammedDahab
    @MuhammedDahab4 жыл бұрын

    I actually took all my stuff and come resided here on your channel ,this becomes my new home , thank you very much , much love

  • @TechWorldwithNana

    @TechWorldwithNana

    4 жыл бұрын

    Awesome :D Glad to hear you like my channel :)

  • @tonyhomfray
    @tonyhomfray4 жыл бұрын

    Great explanations! Really enjoying this video series and actually getting my head around Docker - thanks Nana!

  • @TechWorldwithNana

    @TechWorldwithNana

    4 жыл бұрын

    Thanks Tony, glad you like my explanations :)

  • @sauravparida49
    @sauravparida494 жыл бұрын

    Nana, am loving the way you are making us go through the concepts so clearly in a short amount of time , I had looked other videos but never felt docker this easy

  • @rokofromhell9264
    @rokofromhell92644 жыл бұрын

    Your way of explaining it makes me fully understand each of the concepts, thanks!

  • @TechWorldwithNana

    @TechWorldwithNana

    4 жыл бұрын

    That's nice to hear, thank you!

  • @cedricfitzer4327
    @cedricfitzer43273 жыл бұрын

    just starting out with docker. this was so helpful. thank you very much!!

  • @user-sv8ux8yv8z
    @user-sv8ux8yv8z3 жыл бұрын

    You are amazing. I love your series and channel. Keep up your good work thanks!

  • @maratatt1537
    @maratatt15373 жыл бұрын

    Thank you Nana! It's absolutely a great tutorial.

  • @RaffaelW81
    @RaffaelW814 жыл бұрын

    For me the best beginners-tutorial for Docker I could find on youtube. Many thanks and greetings from Switzerland.

  • @TechWorldwithNana

    @TechWorldwithNana

    3 жыл бұрын

    That's very kind of you Raffael. I appreciate the support. Stay safe Switzerland. 🙂

  • @ssushovan
    @ssushovan3 жыл бұрын

    I must say that, this is by far the best video/tutorial on Docker in KZread. I always had doubt about Dockerfile & Docker-Compose files but, thanks to your excellent videos and explanations. It cleared all my doubts. I'm really grateful to you. Wish I found your channel a lot earlier. Thanks a lot, Nana! :) #Subscribed

  • @10minutescode46
    @10minutescode463 жыл бұрын

    Thanks Nana. This video eradicates some of my confusions.

  • @narendrar9940
    @narendrar99404 жыл бұрын

    First of all thanks again for this video, very clearly explained with detail in simple terms, it is helping me in very much in my work!

  • @TechWorldwithNana

    @TechWorldwithNana

    4 жыл бұрын

    You're welcome! Happy to hear that they help you in your work :)

  • @madhun1875
    @madhun18754 жыл бұрын

    Hello Anna, concepts are very clear and understandable the way you have explained it with the example which makes us to understand very well. really appreciate your effort and hope to watch your more videos. thank you. and I wish all the best.

  • @TechWorldwithNana

    @TechWorldwithNana

    3 жыл бұрын

    You are very much welcome Madhu. I hope this tutorial series has greatly helped you in one way or another. 🙂

  • @taotaotan5671
    @taotaotan56713 жыл бұрын

    That was a great explanation. Subscribed.

  • @tim_bize
    @tim_bize Жыл бұрын

    Great tutorial, Nana!

  • @offisongemmanuel6932
    @offisongemmanuel6932 Жыл бұрын

    You're the best!!!! Thank you so much for this.

  • @SasidaranS
    @SasidaranS2 жыл бұрын

    Thanks a lot Nana, for simple and clear explanations.

  • @juleswombat5309
    @juleswombat53094 жыл бұрын

    That is really cool explanation, especially of the container having its own file system and how to connect into a container. What was missing, was actually a demonstration of using your the app. I presume the host browser could see and connect to the running containerised application, but does this require the Web port mapping are also stated in the Docker file?

  • @vedant6460
    @vedant6460 Жыл бұрын

    Thanks for this video !!!

  • @JamieTwells
    @JamieTwells4 жыл бұрын

    Great video, great instructions.

  • @TechWorldwithNana

    @TechWorldwithNana

    4 жыл бұрын

    Thank you so much!

  • @nandhakumarv6023
    @nandhakumarv602311 ай бұрын

    Excellent teaching. Thanks to Nana

  • @alexsuholitko2528
    @alexsuholitko25282 жыл бұрын

    Great explanation. Thank you 😊

  • @bijanzohouri98
    @bijanzohouri983 жыл бұрын

    Good one, thanks for sharing this video

  • @khrysb.1043
    @khrysb.10433 жыл бұрын

    Your videos are just amazing

  • @bhupathivarma9170
    @bhupathivarma91703 жыл бұрын

    Wooww mam 🙏🙏 awesome explaination..👌👌crisp n clear.. thanks a ton.

  • @josehurtado6871
    @josehurtado687110 ай бұрын

    What an excellent tutorial!!

  • @acronproject
    @acronproject Жыл бұрын

    Good Teacher in World, is you are.

  • @KiranKumar-st9oc
    @KiranKumar-st9oc3 жыл бұрын

    You are a great instructor

  • @ajmalkhalil752
    @ajmalkhalil7522 жыл бұрын

    Thanks, much appreciated.

  • @i.i
    @i.i2 жыл бұрын

    great job thanks

  • @mehrdadvh9479
    @mehrdadvh94792 жыл бұрын

    Thanks for this , its really helpful

  • @riddhimar4810
    @riddhimar48102 жыл бұрын

    Thanks for this!

  • @shadhashmi3714
    @shadhashmi3714 Жыл бұрын

    Your voice makes me crazy you have the most rare voice I have ever heard Excellent video for this topic

  • @tubejim101
    @tubejim1014 жыл бұрын

    Thank you for making these videos

  • @TechWorldwithNana

    @TechWorldwithNana

    3 жыл бұрын

    You're welcome Tubejim. Please share with your friends and spread the knowledge. 🙂

  • @madhusai7021
    @madhusai70214 жыл бұрын

    All Videos r outstanding and I don't know how to say thanks to u. 🤗🤗✌

  • @TechWorldwithNana

    @TechWorldwithNana

    4 жыл бұрын

    Thanks a lot! Support me by subscribing, liking and sharing with others, who would be interested in such videos 🙂

  • @abdul123wahid
    @abdul123wahid4 жыл бұрын

    Thanks Nana. It is very useful to understand.

  • @TechWorldwithNana

    @TechWorldwithNana

    4 жыл бұрын

    Thanks!

  • @sravani-wp6xf
    @sravani-wp6xf3 ай бұрын

    Thanks for your video and explained well

  • @ChandraShekhar-by3cd
    @ChandraShekhar-by3cd8 ай бұрын

    Best informative video ever!

  • @ankitrathore007
    @ankitrathore0074 жыл бұрын

    Great Explanation.. Thanks a lot for bringing such a valuable content.. 🤗

  • @TechWorldwithNana

    @TechWorldwithNana

    3 жыл бұрын

    This is such a joy Ankit. Thank you. 🙂

  • @hamza-325
    @hamza-3253 жыл бұрын

    Thanks for the video, but I think there are two things missing: 1- Exposing the ports in the Dockerfile and attaching them from the run command. 2- Using a Dockerignore file instead of manually moving the files to another directory.

  • @r3jk8
    @r3jk84 ай бұрын

    Thank you so much for making this video. I love you Nana. ❤😂

  • @thagrizzly
    @thagrizzly3 жыл бұрын

    Hi Nana, thank you for your tutorials! I hava question! Where are the environment variables used for? In the server.js these values are hardcoded right?

  • @wrongturn_w
    @wrongturn_w2 жыл бұрын

    This video is so good I felt an urge to throw cash at the screen! How can we support the channel? Patreon? Merch? Paid courses?

  • @TechWorldwithNana

    @TechWorldwithNana

    2 жыл бұрын

    😄 Happy to hear that! I have several paid courses, check out www.techworld-with-nana.com/ Or right below the video it says "THANKS", where you can support me. Thank you so much in advance! :)

  • @okonkwo.ify18

    @okonkwo.ify18

    2 жыл бұрын

    I can throw in my btc wallet address for her 😂

  • @djnikhil058
    @djnikhil0584 жыл бұрын

    @TechWorld with Nana : Thanks for this , its really helpful. Most of the concepts are cleared with you Docker in Practice Course. Really Appreciated :)

  • @TechWorldwithNana

    @TechWorldwithNana

    3 жыл бұрын

    You're welcome Nikhil. I'm grateful for the opportunity to help. 🙂

  • @nanditasahu2358
    @nanditasahu23582 жыл бұрын

    Clear Explanation.

  • @yassinsoltani2725
    @yassinsoltani27254 жыл бұрын

    you are the best ! thank you so much

  • @TechWorldwithNana

    @TechWorldwithNana

    4 жыл бұрын

    Thanks a lot Yassin! :)

  • @lakshmib412
    @lakshmib4123 жыл бұрын

    Thank you it's very helpful

  • @Lunolux
    @Lunolux Жыл бұрын

    great video, thx

  • @juanramon4954
    @juanramon49542 жыл бұрын

    Very well explained

  • @zamora322
    @zamora3222 жыл бұрын

    Nana, thanks for sharing.

  • @nicetomeetugaming7024
    @nicetomeetugaming70242 жыл бұрын

    Thanks for this amazing video mam!

  • @muratcan__22
    @muratcan__22 Жыл бұрын

    you are so good!

  • @vedant6460
    @vedant6460 Жыл бұрын

    Thanks a lot for this video !!!

  • @maridubois842
    @maridubois8423 жыл бұрын

    Best explanation ever!!

  • @TechWorldwithNana

    @TechWorldwithNana

    3 жыл бұрын

    Thank you 😊

  • @oateurman
    @oateurman3 жыл бұрын

    You 're really really good at explaining Docker clearly - will recommend to my data science students

  • @jpf504
    @jpf5042 жыл бұрын

    you are the best...

  • @osmoofnybble
    @osmoofnybble2 жыл бұрын

    Thanks!

  • @siddheshdeshmukh3635
    @siddheshdeshmukh363511 ай бұрын

    I watch your video and clear my doubt since I was not able to clear last three days ♥️♥️♥️♥️

  • @anexiole
    @anexiole2 жыл бұрын

    thank you :)

  • @avinashnew
    @avinashnew2 жыл бұрын

    Thank you

  • @MrKlassic-f7j
    @MrKlassic-f7j23 күн бұрын

    thank you!!!

  • @HemangJoshi
    @HemangJoshi4 жыл бұрын

    awesome videos maam...

  • @nareshkaayth4477
    @nareshkaayth4477 Жыл бұрын

    Hi Nana @TechWorld with Nana, Thanks for this amazing video of making a docker image. I am having one question. How we can run our image that depends on some other images as whole application like in this video, we have used MONGODB and MONGO-EPRESS UI images for storing the data in DB. In last 2 minutes you said we can run the docker image from docker compose. May i know we can do that..?? ...Thanks

  • @dipankarrahuldey6249
    @dipankarrahuldey62492 жыл бұрын

    Basically the RUN command is like running a command during building the image, and when the image build is done, the command to be executed is written as CMD.

  • @alivalizada8543
    @alivalizada85432 жыл бұрын

    Thanks

  • @riteshtaksali
    @riteshtaksali6 ай бұрын

    Perfect

  • @parteekbhatia
    @parteekbhatiaАй бұрын

    Dear Nana, thanks for creating very simple and informative playlist, I am exceuting all the code mentioned in the playlist and i am able to follow everything you presneted in this. Now at this stage when we are running our app image as container, we are getting the message app is listening at port 3000. But when i open this on brower it is not showing anythinb. Why this is happening? In order to run this from our image what steps I need to follow.

  • @jorgepadilla392
    @jorgepadilla3924 жыл бұрын

    Hi, thank you for the detail explanations, these tutorial are very good and to the point. I wanted to ask you if you something on secrets using docker-compose and also any BuildKit tutorials for docker? Thank you!

  • @TechWorldwithNana

    @TechWorldwithNana

    4 жыл бұрын

    Thanks Jorge, regarding your question "secrets using docker-compose and also any BuildKit tutorials for docker" sure you can ask, what do you mean exactly, do you have any example?

  • @jorgepadilla392

    @jorgepadilla392

    4 жыл бұрын

    @@TechWorldwithNana thank you, I think I figured it out, but your videos are very helpful and well explained. I am watching your kubernetes ones now. I appreciate your time and effort putting these together.

  • @ahmedjarraya1739
    @ahmedjarraya17393 жыл бұрын

    Hello Nana, i have a question let's suppose that i'm having a microservice app in which i'm using jenkins for continous integration for each microservice(each microservice has its own git repo in which i have specified the jenkinsfile, the src code and the dockerfile in order to build images for the genearted artifacts and pull them in dockerhub )How each image will talk to each other (i'm not going to build docker network manually i guess every thing should be done automatised )

  • @armankarimi9209
    @armankarimi92092 жыл бұрын

    Docker official tutorials are very bad... But you explain them like it is the easiest thing in the world! Thanks Nana

  • @MichaelSalo
    @MichaelSalo2 жыл бұрын

    It seems like the container isn't created until the deploy step. Would we ever want to create a container earlier, during development?

  • @okonkwo.ify18
    @okonkwo.ify182 жыл бұрын

    Before building the image , I would v loved to take a look at your code if it had a .env file.

  • @johnnybravo2665
    @johnnybravo26653 жыл бұрын

    Hi! is it possible to change code without rebuilding image ? If we can, then pls tell how?

  • @thedacian123
    @thedacian123 Жыл бұрын

    what about dockerfile workdir command.After you copy from host to container woud not be fine to set workdir to /home/app so that each further command as run will be executing in the WORKDIR container directory?Thank you

  • @cpManikanta
    @cpManikanta3 жыл бұрын

    Hi Nina thanks for video but there is some more content I expected like downloading the artifact from repo whith login into that prvt artifact by encrypting the login details and building the image with that artifact

  • @somnathchoudhuri
    @somnathchoudhuri5 ай бұрын

    Informative and useful video. Two things 1. For windows ENV settings, do we use / or // or \ or \\ for PATHs 2. For java classpath, is it ["java","-cp"] or ["java","-classpath"] or ENV CLASSPATH? I would really appreciate it if you could go indepth into Dockerfiles for Java-Maven and Java-SpringBoot-Maven projects. Thanks again for your educational videos

  • @msurajnair7149
    @msurajnair71493 жыл бұрын

    Thank you So much Nana, The concept was explained so nicely. I Just have one query, Can we implement docker volume in docker file if yes, then how? (I tried to search for related video content but could not find any) You did explain in this video how we can copy the content of a local directory in to the container while creating one which is good.

  • @ajitjagtap4495

    @ajitjagtap4495

    Жыл бұрын

    Hello you use docker bind concept

  • @smrutiranjanpatra7186
    @smrutiranjanpatra7186 Жыл бұрын

    Hi Nana, what is the use of STOPSIGNAL in Dockerfile. Can you please explain with a example.

  • @heenasejwal6953
    @heenasejwal69533 жыл бұрын

    U are awesome, god bless u NANA

  • @TechWorldwithNana

    @TechWorldwithNana

    3 жыл бұрын

    Thank you Heena. Please don't forget to share with your friends. 🙂

  • @cpManikanta
    @cpManikanta3 жыл бұрын

    It will be helpfull if it explained by using build command and by using jenkins to build container

  • @pavankumard5276
    @pavankumard52765 ай бұрын

    I have a question. In this docker file all we are doing is running node server.js, but what about the dependencies on mongo and mongo-express containers? Shouldn’t we include them as well as part of the Dockerfile?

  • @ebiscaia
    @ebiscaia3 жыл бұрын

    Hi, How can I see a docker-file when the publisher hasn't put it on Docker Hub and there is no Git page? Also, you can use docker run --restart unless-stopped to ensure the container will restart after a reboot. Is it possible to do the same using docker compose? Thanks, Eduardo

  • @ronanmacfhlannchadha7774
    @ronanmacfhlannchadha77742 жыл бұрын

    Probably should cover ENTRYPOINT and LABELS also

  • @user-xg7hi5mh3g
    @user-xg7hi5mh3g19 күн бұрын

    When I want to learn about Docker I just type Docker Nana if i didnt save the video. U re simply great in explaining Docker, also DevOps 😊. My question is about Dockerfile. I am trying to create an avalonia app inside a Docker Image. The app should run using the weston compositor in Ubuntu environment. I have already Avalonia running using X11 but I would like to use the weston compositor Any help ? Thank you for your great Videos

  • @srikumar9176
    @srikumar91764 жыл бұрын

    Thanks for the clear explanations..!! After deploying my-app as container, the browser just shows empty page, tried to debug but no luck. Any idea, why?? However when my-app is run on host machine, I was able to see output in the browser and connects to mongodb container without any issues.

  • @queenofpain6483

    @queenofpain6483

    3 жыл бұрын

    same i just encountered the same issue. Were you able to solve it?

  • @hamza-325

    @hamza-325

    3 жыл бұрын

    I didn't follow this tutorial, but I think that she forgot to expose the port 3000 that is used by the Node server. I think that she had to write an EXPOSE command in the Dockerfile and add -d 3000:3000 to the docker run command.

  • @TimothyHuey

    @TimothyHuey

    Жыл бұрын

    @@queenofpain6483 the solution that worked for me was to change the line let mongoUrlLocal = "mongodb://admin:password@localhost:27017"; to let mongoUrlLocal = "mongodb://admin:password@mongodb:27017"; I will post at top. Several people are saying they are having the same problem. My environment is WSL2 on Windows so my fix may be specific to that environment or may be more widely applicable.

  • @gustavobarbosa7493
    @gustavobarbosa74937 ай бұрын

    If I don't set an SO in my Dockerfile, will docker take the SO from the host system?

  • @pavankumard5276
    @pavankumard52765 ай бұрын

    As part of this Dockerfile why are we not doing RUN npm install?

  • @josephkingstonleomariamich7220
    @josephkingstonleomariamich72203 жыл бұрын

    All tutorials are really awesome, pls consider using the white background in the terminal and in visual studio kind of tools, in a small screen it is really hard to see things on a black screen. Thanks.

  • @ahmedAmmar2006
    @ahmedAmmar20062 жыл бұрын

    please why we ignore the mongodb image when creating the docker file as its necessary for our application

  • @DarkCebolix
    @DarkCebolix11 ай бұрын

    tks

  • @bharathir8688
    @bharathir86882 жыл бұрын

    Hi, I need to copy files that are generated in one container to another. How can I do that?

  • @zeeshanali2805
    @zeeshanali28052 жыл бұрын

    Does running app with docker file will it run only app or both app and mongodb. Because in my case it is running app only and when I open browser the content of site at 3000 port is blank. And I am guessing it because of my mongodb is not running what say! Kindly please answer my query

  • @miemiemyothant627
    @miemiemyothant6272 жыл бұрын

    When i run this docker build command , it showed me this error failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount595932089/Dockerfile: no such file or directory Thank you Nana!

  • @chad136
    @chad1362 жыл бұрын

    If your docker instance is on a network that is isolated from the internet, can you download and then specify the node:alpine-13 image?

  • @MrSHowVIdeo

    @MrSHowVIdeo

    2 жыл бұрын

    I'm probably too late to answer u but I'm sure u can download images from another computer and pull images from that computer to ur isolated instance using scp , rsync or sftp or whatever other cool tool of ur choice without issues.

  • @marctowersap8018
    @marctowersap80184 жыл бұрын

    weird, I cannot connect to the database. I start it up, and I see it is unable to connect to database. My URL is "mongodb://mongoadmin:password123@localhost:27017"; I can connect to it via mongo-express, it worked before I put the node.js code into a image. node server works, I can see it connected to a database, "node". I stop it, then start the container, and "/home/nodeapp/server.js" fails with the unable to connect to database. If I changed the URL fro localhost to mongodb (the name of my container) and joined the container to the mongo network, then it starts up

  • @TechWorldwithNana

    @TechWorldwithNana

    4 жыл бұрын

    when you start the node app as a docker container, it must connect to MongoDB (another docker container) using the name (mongo), not the host:port. That's why before you build the image from node app, you must adjust the db url to mongodb://mongoadmin:password123@mongo. Of course the db url in practice will be set from outside, so you don't have to adjust it back and forth all the time. But this is how it works, just to understand the concept. Let me know if you have any further questions.

  • @user-xg7hi5mh3g
    @user-xg7hi5mh3g5 ай бұрын

    Best teacher :) , I ve two qst: 1 . I become an error by building the image because of the encoding , the Dockerfile is in UTF16 encodoing how I could fix this to be in UTF8 2. Can I run/deploy windows based images in Linux host