[ASP.NET] Docker build not working properly.
so basically i made and pushed a docker image to the hub repositoory. And everytime i push to github, there is a github action that also updates the docker image and then on render.com is updated too. so my docker image works fine for deploying to a cloud provider.
but the problem is that if i want other people to pull my docker image from online and run it locally, they are unable to do that. when i pull and then run
docker compose up
, I get the following error:26 Replies
this doesnt make sense to me cause the .sln file is in the same directory as the
compose.yaml
and the Dockerfile
, so why is it saying th eabove?
could anyone help me with this?what does your compose file look like? Because the output above looks like you are attempting to build a container, not pull and run an existing one.
my compose.yaml looks like this:
i dont want to spam this chat, so here is my Dockerfile
That compose file is never going to run the image that github deploys, it will only build a new one locally.
i know, i have to do
docker pull image_name:latest
to get the image, and then it shows up in Docker Hub. and then after that I do docker compose up --build
to get the postgres image to show up as the database. and then im supposed to do docker run
right? am i misunderstanding this?there is no reason to do
docker-compose up --build
when creating running a container pulled from a registry
and also no reason to use docker run
either
docker-compose up
will
1) build any images that specify dockerifles / build contexts
2) pull any images not found in your local cache
3) start the containers
As for this error, I don't have any suggestions outside of adding in additional steps to write the contents of the current directory to console.
If you want to test the image that is getting deployed to github, I'd honestly just create a new compose file and put it somewhere elsei dont really understand to be honest, is tarted learnign docker a few days ago. but when i do
docker pull
then i have to do docker run
next right? but when I do i see this in the console:
and then when i go to localhost:8080 in the browser, i get the above error.and then when i look in my docker hub, i dont see my postgres image
are you actually using
docker pull
and docker run
, or are you using docker-compose
?no i am doing
docker pull jbrown58/realtime-poll
and then docker run jbrown58/realtime-poll
that is your problem,
docker
and docker-compose
behave very differently
docker run
requires you to manually pass in all of the configuration options needed to make a container work properly (exposing ports, mounting paths, etc)
docker-compose
reads from a docker-compose.yml
file that lets you configure the container
So when you do docker run jbrown58/realtime-poll
, it has no idea that a database is required for things to work. It also doesn't know that it should be exposing your app on port 8080
ok
so i should always use
docker-compose
since i am using a compose.yaml
?yup
ok
one sec
ok i did
docker compose pull
, and i see my postgres database now, but it didnt also bring the app with itit is kind of the opposite of before when it would bring the app but not the database
docker-compose pull
does not start containers, it only downloads the most recent version of the image (if the local one is outdated)but this image is just the database, is my app not part of the multi container?
^ ok that probbaly doesnt make any sense i think cause, you pull images not container
What is the exact command you used?
i did
docker-compose run jbrown58/realtime-poll
but it said no such service: jbrown58/realtime-poll
and didnt do anything, so i googled and it said that you haev to do docker-compose pull
and then do the previous command but that didn twork eitherok, it seems you are misunderstanding how
docker-compose
works in generalyes i think so, i remember when i was using docker-compose at first but i stopped using it for some reason
Docker Documentation
How Compose works
Understand how Compose works and the Compose application model with an illustrative example
If you haven't read the docs on how compose works, I'd suggest you take a look at them
But I'll give a quick TL;DR on some of the more common commands
up
- starts containers that you have defined in your compose file. Can start all or specify specific services to run.
If you want to start your app only, you'd do docker-compose up -d server
because, in your compose file, the app's service is named server
down
- stops containers
build
- builds all services that specify a build
section in their config
pull
- pulls the latest versions for all services that use an image
Docs for the compose CLI can be found here: https://docs.docker.com/compose/reference/
ok thank you