nest-api docker-compose up - docker

Hi im creation a micro service using nestjs on back end and i`m depare with this messagem error on terminal
`version: '3'
services:
app:
build:
entrypoint: ./.docker/entrypoint.sh
ports:
- 3000:3000
volumes:
- .:/home/node/app`
please help me
resolution for a problem

Related

docker-compose gives error: no such service

Im trying to deploy with docker compose an app; mi yml is:
version: '3.9'
services:
db:
image: mongo
restart: always
volumes:
- 'dbdata:/data/db'
container_name: database
server:
build: .
restart: always
ports:
- '2000:2000'
depends_on:
- db
container_name: api
links:
- database
frontend:
build: ./client
restart: always
ports:
- '3000:3000'
depends_on:
- server
container_name: client
links:
- api
volumes:
dbdata:
When i docker compose up -d this in my PC it works correctly, but when i do the same thing in a oracle linux 8.6 fedora; seems like is working fine until came to the lines:
Network soccer_default Created
no such service: database
And stop the process. Is something related with the machine or docker version?

Containers run well independently but not in docker compose

I have an app with separated frontend and backend, each one is a subfolder. I have dockerized the front and the back separately in their folders, respectively.
Now, I'm trying to run them in the same network by using docker-compose in the root folder. The build is done successfully, but when I run it, the front container works just fine, but the back container exits with code 0.
Maybe it's worth mentioning that the container of the back is a done with a docker-compose too.
Can you help me please?
Here's how the docker-compose.yml looks like in the root folder
version: '3.7'
services:
back:
build: ./backend/
ports:
- "8000:8000"
front:
build: ./frontend/
ports:
- "80:3000"
output:
app_back_1 exited with code 0
front_1 | INFO: Accepting connections at http://localhost:3000.
Here's the docker-compose file of the backend:
version: '3.5'
services:
app:
build:
context: .
command: gunicorn backend.wsgi:application --bind 0.0.0.0:8000
volumes:
- static_data:/vol/static
ports:
- "8000:8000"
restart: always
env_file:
- .env
depends_on:
- app-db
app-db:
image: postgres:12-alpine
ports:
- "5432:5432"
restart: always
volumes:
- postgres_data:/var/lib/postgresql/data:rw
env_file:
- .env
proxy:
build: ./proxy
volumes:
- static_data:/vol/static
- media_data:/vol/media
restart: always
ports:
- "8008:80"
depends_on:
- app
volumes:
static_data:
media_data:
postgres_data:
If the container runs well, It should run well with identical docker image that you have built. Try docker-compose up --build --force-recreate --no-deps to recreate everything from scratch with no cache, so then if you have error in your source code the error will throw for both standalone container and compose.

Communication between two .net core containers

net core application. I have webapp and api application.
Below is my docker-compose file.
version: '3.4'
services:
enrichment.webapi:
container_name: enrichment.webapi
ports:
- 8000:80
- 8001:443
environment:
- "ASPNETCORE_URLS=https://+;http://+"
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=mypassword
volumes:
- ./conf.d/https/:/https/
build:
context: .
dockerfile: Enrichment.WebApi/Dockerfile
enrichment.webapp:
image: enrichment.web
ports:
- 7000:80
- 7001:443
environment:
- "ASPNETCORE_URLS=https://+;http://+"
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=mypassword
volumes:
- ./conf.d/https/:/https/
build:
context: .
dockerfile: Enrichment.Web/Dockerfile
depends_on:
- enrichment.webapi
When I do docker-compose up I see below when I do docker ps
0.0.0.0:8000->80/tcp, 0.0.0.0:32835->80/tcp, 0.0.0.0:8001->443/tcp, 0.0.0.0:32834->443/tcp
for the api app. When I do https://localhost:32834/index.html it works fine. But this port 32834 dynamically assigned. I want to set some static port so that I can handle my CORS in my web app. Each time this port is keep on getting changed when I rebuild docker-compose file. So Is there any way to handle this. Any help would be appreciated. Thanks

Fail to resolve docker compose service name from front end

Hi I'm new to using docker for development. I'm trying to communicate from frontend (react) to the backend (express.js) here.
I have enabled cors as well, I'm getting an error saying net::ERR_NAME_NOT_RESOLVED when trying to fetch from the back end using the url http://backend:4001,
but it's working when I use the docker internal IPAddress, like: http://172.18.0.3:4001.
Following is my docker-compose.yml file.
Please advise on getting this working, thanks.
version: "3"
services:
backend:
build: ./api
volumes:
- ./api:/usr/src/api
ports:
- 6002:4001
depends_on:
- database
database:
image: mongo:4.0.15-xenial
ports:
- 27018:27017
frontend:
build: ./app
volumes:
- ./app:/usr/src/app
ports:
- 6001:3000
links:
- backend
depends_on:
- backend
It will not work, because your browser(internet client) is not part of docker stack network, you have to configure you frontend service to connect to http://localhost:6002 instead of http://backend:4001

How to share enviroment variables in docker

I´m new to docker and I´m having lots of troubles to make it start. I´m making an asp.net core 1.0.1 application user docker container tools for visual studio 2017. I have the following env.file in the same root as the compose file with this values:
REDIS_PORT=6379
and this docker compose yml:
version: '2'
services:
haproxy:
image: eeacms/haproxy
links:
- webapplication3
ports:
- "80:80"
webapplication3:
image: webapplication3
enviroment:
- REDIS_PORT=${REDIS_PORT}
build:
context: .
dockerfile: Dockerfile
links:
- redis
ports:
- "80"
redis:
image: redis
ports:
- ${REDIS_PORT}
I want to know the redis port I have to connect to from my Asp.net core app. As far as I know, the only way to do it is using env variables, and since I don´t want to copy paste the port everywhere I´d like to use the .env file style. Anyway this is not working saying:
Unsupported config option for services.webapplication3:'enviroment'
Any ideas what the problem could be?
You missed a letter "n" in a word environment.
You need to pass the env_file option:
version: '2'
services:
haproxy:
image: eeacms/haproxy
links:
- webapplication3
ports:
- "80:80"
webapplication3:
image: webapplication3
env_file:
- env.file
environment:
- REDIS_PORT=${REDIS_PORT}
build:
context: .
dockerfile: Dockerfile
links:
- redis
ports:
- "80"
redis:
image: redis
env_file:
- env.file
ports:
- ${REDIS_PORT}
Take a look at https://docs.docker.com/compose/environment-variables/ for more info.

Resources