Docker Compose unable to use https - docker

This is my docker compose file:
version: '3.4'
services:
appone.api:
image: ${DOCKER_REGISTRY-}apponeapi
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
- ASPNETCORE_Kestrel__Certificates__Default__Password=
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/AppOne.Api.pfx
build:
context: .
dockerfile: AppOne.Api/Dockerfile
networks:
- ${NETWORK}
ports:
- "59541:80"
- "59542:443"
volumes:
- ~/.aspnet/https:/https:ro
networks:
dev-network:
name: ${NETWORK}
When I try to connect to https://localhost:59542/values via Postman, it will fail saying
Error: Client network socket disconnected before secure TLS connection
was established
This is how I start it:
docker-compose -f docker-compose.yml up --force-recreate --build -d
docker image prune -f
Am I missing something? If I remove https://+443 and the port 443 reference, I am able to connect using http only via port 59541

Related

Docker compose django, nginx, daphne expose internet in EC2

Hello i need expose the containers to internet i read thats is with ip table and works in in the instance but i can't access by internet for the moment and this is my configuration:
EC2 instance:
Ubuntu
Docker vserions:
Docker version 20.10.7, build f0df350
docker-compose version 1.25.0, build unknown
docker-compose.yml
version: '3.1'
services:
redis:
image: redis
command: redis-server --port 6379
ports:
- '6379:6379'
environment:
- REDIS_MODE="LRU"
- REDIS_MAXMEMORY="800mb"
server:
build: .
command: daphne rubrica.asgi:application --port 8000 --websocket_timeout -1 --bind 0.0.0.0 -v2
volumes:
- .:/src
- ${AWS_CREDENTIALS_PATH}:/root/.aws/
ports:
- "8000:8000"
links:
- redis
env_file:
- .env
nginx:
image: nginx
volumes:
- ./nginx/:/etc/nginx/
links:
- server
ports:
- "80:80"
- "443:443"
depends_on:
- server
command: ["nginx", "-g", "daemon off;"]
networks:
docker-network:
driver: networktest
network
sudo docker create --name networktest --network <instance ip> --publish 8080:80 --publish 443:443 nginx:latest
and this is the rules in my instance
If someone can help me to know what i need or a can't see in the configuration.

Port exposed with docker run but not docker-compose up

I am trying to run rabbitmq along with influxdb TICK stack with docker-compose. When I run rabbitmq with this command:docker run -d --rm -p 5672:5672 -p 15672:15672 rabbitmq:3-management, both ports are open and I am able to access from a remote machine. However, when I run rabbitmq as part of a docker-compose file, it is not accessable from a remote machine. Here is my docker-compose.yml file:
version: "3.7"
services:
influxdb:
image: influxdb
volumes:
- ./influxdb/influxdb/data/:/var/lib/influxdb/
- ./influxdb/influxdb/config/:/etc/influxdb/
ports:
- "8086:8086"
rabbitmq:
image: rabbitmq:3-management
volumes:
- ./rabbitmq/data:/var/lib/rabbitmq
ports:
- "15672:15672"
- "5672:5627"
telegraf:
image: telegraf
volumes:
- ./influxdb/telegraf/config/:/etc/telegraf/
- /proc:/host/proc:ro
depends_on:
- "influxdb"
- "rabbitmq"
chronograf:
image: chronograf
volumes:
- ./influxdb/chronograf/data/:/var/lib/chronograf/
ports:
- "8888:8888"
depends_on:
- "telegraf"
More information: when I run this with docker-compose up -d the 8086 and 8888 are accessible from a remote machine (I confirm with using nmap command). Also, either way I am able to access the rabbitmq management console at http://localhost:15672.
How can I set this up so I can access rabbitmq from a remote machine using docker-compose?
Thank you.
Looks like just a typo in the port mapping in docker-compose.yml: 5672:5627 should actually be 5672:5672.
Otherwise the docker-compose configuration looks just fine.

Docker-compose bridge network & host remote port forwarding at the same container

I'm trying to make service that can forward remote database port to container and at the same time can be accessible by alias hostname from other containers to work with them.
I am think that make all containers communicate by host network is bad practice, so i am trying to setup that configuration.
When i am triyng to add to php-fpm service network with driver: host, docker says
only one instance of "host" network is allowed
When i am trying to set php-fpm service with this
networks
- host
Docker says that he cant find out network with this name.
When i try to define network in docker-compose by id of built-in host, it just cant start this container.
This is my docker-compose:
version: '3.2'
networks:
backend-network:
driver: bridge
frontend-network:
driver: bridge
volumes:
redis-data:
home-dir:
services:
&app-service app: &app-service-template
build:
context: ./docker/app
dockerfile: Dockerfile
volumes:
- ./src:/app:rw
- home-dir:/home/user
hostname: *app-service
environment:
FPM_PORT: &php-fpm-port 9001
FPM_USER: "${USER_ID:-1000}"
FPM_GROUP: "${GROUP_ID:-1000}"
APP_ENV: local
HOME: /home/user
command: keep-alive.sh
networks:
- backend-network
&php-fpm-service php-fpm:
<<: *app-service-template
user: 'root:root'
restart: always
hostname: *php-fpm-service
ports: [*php-fpm-port]
environment:
FPM_PORT: *php-fpm-port
FPM_USER: "${USER_ID:-1000}"
FPM_GROUP: "${GROUP_ID:-1000}"
APP_ENV: local
HOME: /home/user
entrypoint: /fpm-entrypoint.sh
command: php-fpm --nodaemonize -R -d "opcache.enable=0" -d "display_startup_errors=On" -d "display_errors=On" -d "error_reporting=E_ALL"
networks:
- backend-network
- frontend-network
nginx:
build:
context: ./docker/nginx
dockerfile: Dockerfile
restart: always
working_dir: /usr/share/nginx/html
environment:
FPM_HOST: *php-fpm-service
FPM_PORT: *php-fpm-port
ROOT_DIR: '/app/public' # App path must equals with php-fpm container path
volumes:
- ./src:/app:ro
ports: ['9999:80']
depends_on:
- *php-fpm-service
networks:
- frontend-network
Network scheme (question about green line):
Host works on Debian 7 (updates prohibited) and conainer works with lastest Alpine

connection refused from host to docker container

I'm trying to run a web app within a docker container. This is my docker-compose.yml
version: '2'
services:
web-app:
image: org/webapp
container_name: web-app
ports:
- "8080:8080"
expose:
- "8080"
volumes:
- ./code/source:/source
command: tail -f /dev/null
postgres:
image: postgres:9.5
container_name: local-postgres9.5
volumes_from:
- postgres-data
postgres-data:
image: busybox
container_name: postgres9.5-data
volumes:
- /var/lib/postgresql/data
When I run
docker-compose up -d
I'm able to connect to the web app from within the container with a curl command. When I try to connect from the host, I get a connection refused error

Docker-compose Error

Currently, I have set up 'nginx' and 'php-fpm' using 'docker-compose' like below. Nginx connects to php:9000, however, web server gives me 502 Bad Gateway error. I assume docker-compose command didn't link nginx and php-fpm correctly.
Any advice or suggestion? Thanks in advance.
version: '2'
services:
nginx:
container_name: nginx
image: wb/truckup-nginx:latest # private repo
#network_mode: 'bridge'
depends_on:
- php
volumes_from:
- php
ports:
- 443:443
- 80:80
links:
- php
php:
container_name: php
ports:
- 9000:9000
image: wb/truckup-app:0.1 # private repo
#environment:
#MYSQL_HOST: mysql
#MYSQL_USER: root
#MYSQL_PASSWORD: passme
#MYSQL_DATABASE: database
#데이터 볼륨 컨테이너 안의 데이터 볼륨 디렉터리에 접근가능
volumes:
- /home/*:/home/*
I think your compose-file is correct. To recheck link command run probaly or not. You can exec to your nginx container
docker exec -it nginx bash
and ping to php container using
ping php
if everything is ok, recheck your image.

Resources