How to configure dns-proxy-server in docker-compose to bind to a non-default IP address - dns

I am using mageddo/dns-proxy-server in my RoR environment to provide DNS resolution for the docker containers. This works like a treat until I connect to the company VPN. Unfortunately, dns-proxy-server binds to the port 172.17.0.2 which conflicts with the VPN. My other containers are using a different IP range. Here is the docker-compose file:
version: '3.7'
services:
jet-db:
image: postgres:latest
hostname: jet-db
ports:
- 5432:5432
environment:
POSTGRES_USER: '*'
POSTGRES_PASSWORD: '*'
volumes:
- database_data:/var/lib/postgresql/data
sidekiq:
build:
context: .
dockerfile: docker/app/ruby-on-rails.dockerfile
command: bundle exec sidekiq -v
environment:
POSTGRES_URL: 'postgres://db/'
RAILS_CACHE_URL: 'redis://rails-cache:6380/'
links:
- jet-db
- sidekiq-cache
- rails-cache
volumes:
- '.:/app'
sidekiq-cache:
image: redis
hostname: sidekiq-cache
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- 6379:6379
volumes:
- ./docker/redis/sidekiq.conf:/usr/local/etc/redis/redis.conf
rails-cache:
image: redis
hostname: rails-cache
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- 6380:6380
volumes:
- ./docker/redis/rails-cache.conf:/usr/local/etc/redis/redis.conf
mailcatcher:
image: zolweb/docker-mailcatcher:latest
ports:
- "1025:1025"
- "1080:1080"
dns-proxy-server:
image: defreitas/dns-proxy-server:latest
hostname: dns.mageddo
volumes:
- /opt/dns-proxy-server/conf:/app/conf
- /var/run/docker.sock:/var/run/docker.sock
- /etc/resolv.conf:/etc/resolv.conf
network_mode: bridge
ports:
- "5380:5380"
volumes:
database_data:
driver: local
tmp:
driver: local
networks:
default:
driver: bridge
ipam:
config:
- subnet: 169.10.0.0/16
Here is what /etc/resolv.conf looks like when the proxy is running normally without VPN:
:# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
# nameserver 8.8.8.8 # dps-comment
# nameserver 127.0.0.53 # dps-comment
nameserver 172.17.0.2 # dps-entry
I am wondering whether there is a way to get dns-proxy-server to bind to a different IP address to avoid the conflict with the VPN.

Related

Docker Cassandra Access in Client Running Under Same Docker

My docker-compose file as below,
cassandra-db:
container_name: cassandra-db
image: cassandra:4.0-beta1
ports:
- "9042:9042"
restart: on-failure
volumes:
- ./out/cassandra_data:/var/lib/cassandra
environment:
- CASSANDRA_CLUSTER_NAME='cassandra-cluster'
- CASSANDRA_NUM_TOKENS=256
- CASSANDRA_RPC_ADDRESS=0.0.0.0
networks:
- my-network
client-service:
container_name: client-service
image: client-service
environment:
- SPRING_PROFILES_ACTIVE=dev
ports:
- 8087:8087
links:
- cassandra-db
networks:
- my-network
networks:
my-network:
I use Datastax Java driver to connect cassandra in client service, which also runs inside docker.
CqlSession.builder()
.addContactEndPoint(new DefaultEndPoint(
InetSocketAddress.createUnresolved("cassandra-db",9042)))
.withKeyspace(CassandraConstant.KEY_SPACE_NAME.getValue())
.build()
I use DNS name to connect but not connected, i tried with Docker IP of cassandra container, and depends-on also.
Any issue with docker-compose file?

How to find FTP Host and username and password in docker

I'm running two webs on docker both using joomla one with 127.0.0.1:8383 and another one with 127.0.0.1:8181. in the web that has the address 127.0.0.1:8383 should connect to the other one so I need to know the Host the username and the password of ftp for 127.0.0.1:8181. I didn't find any command that I can use it on docker server that is linux to find this information (FTP HOST; FTP USERNAME; FTP PASSWORD).
docker network ls return
NETWORK ID NAME DRIVER SCOPE
f37b31437406 bridge bridge local
6677ac044ead host host local
57d840968a45 none null local
461f00275394 site_default bridge local
3ea97a6df8a8 sitea1_default bridge local
127.0.0.1:8181 docker-compose.yml
version: '3.1'
services:
web:
build:
context: ./
dockerfile: docker/web/Dockerfile
restart: always
ports:
- "8181:80"
volumes:
- .:/alpha
phpmyadmin:
image: phpmyadmin/phpmyadmin
depends_on:
- mysql
ports:
- "8282:80"
environment:
PMA_HOST: mysql
MYSQL_ROOT_PASSWORD: alpha
mysql:
build:
context: ./
dockerfile: docker/database/Dockerfile
restart: always
environment:
MYSQL_ROOT_PASSWORD: alpha
MYSQL_DATABASE: alpha
MYSQL_USER: alpha
MYSQL_PASSWORD: alpha
volumes:
- my-db:/var/lib/mysql
volumes:
my-db:
127.0.0.1:8383 docker-compose.yml
version: '3.1'
services:
joomla:
image: joomla
restart: always
links:
- joomladb:mysql
ports:
- 8383:80
volumes:
- "./:/var/www/html"
environment:
JOOMLA_DB_HOST: joomladb
JOOMLA_DB_PASSWORD: alpha
joomladb:
image: mysql:5.6
ports:
- 3306
restart: always
volumes:
- "./data:/var/lib/mysql"
environment:
MYSQL_ROOT_PASSWORD: alpha
MYSQL_DATABASE: alpha
MYSQL_USER: alpha
I already installed ftp on server
sudo apt-get update
sudo apt-get install vsftpd
The question is unclear and it does not exist any FTP command in docker.
A best practice is to create a new FTP container and linking it to your web app container.

Define Ip of docker-compose file

i'm kinda new to docker so sorry if my terminology is a little wrong. I'm in the process of getting my app to run in docker. Everything is starting up and running correctly but i'm unable to set the ip address that the services are running on. I need to do so since i'm making api calls that previously referenced a static variable in my js code. The spark service especially is important for me to have a knowable ip, as of now its randomly assigned.
docker-compose.yml
version: '3.0' # specify docker-compose version
services:
vue:
build: client
ports:
- "80:80" # specify port mapping
spark:
build: accubrew-spark
ports:
- "8080:8080"
express:
build: server
ports:
- "3000:3000"
links:
- database
database:
image: mongo
ports:
- "27017:27017"```
When you're running containers using docker-compose it creates a user-defined network for you and docker provides an embedded DNS servers, each container will have a record resolvable only within the containers of the network.
This makes it easy for you to know how to contact each service by just calling them by the name you specified on your docker-compose.yml.
You can try this:
version: '3.0' # specify docker-compose version
services:
vue:
build: client
ports:
- "80:80" # specify port mapping
spark:
build: accubrew-spark
ports:
- "8080:8080"
networks:
my_net:
ipv4_address: 172.26.0.3
express:
build: server
ports:
- "3000:3000"
links:
- database
database:
image: mongo
ports:
- "27017:27017"
networks:
my_net:
ipam:
driver: default
config:
- subnet: 172.26.0.0/16
But yours spark port is localhost:8080, if you need to expose other port with the ip 172.26.0.0, you can do - "7077" or with the localhost: -"7077:7077" this is an example with the port 7077 expose:
version: '3.0' # specify docker-compose version
services:
vue:
build: client
ports:
- "80:80" # specify port mapping
spark:
build: accubrew-spark
ports:
- "8080:8080"
- "7077"
networks:
my_net:
ipv4_address: 172.26.0.3
express:
build: server
ports:
- "3000:3000"
links:
- database
database:
image: mongo
ports:
- "27017:27017"
networks:
my_net:
ipam:
driver: default
config:
- subnet: 172.26.0.0/16

call a docker container by it name

I would like to know if it's possible to use my docker container name as host instead of the IP.
Let me explain, here's my docker-compose file :
version : "3"
services:
pandacola-logger:
build: ./
networks:
- logger_db
volumes:
- "./:/app"
ports:
- 8060:8060
- 10060:10060
command: npm run dev
logger-mysql:
image: mysql
networks:
- logger_db
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: Carotte1988-
MYSQL_DATABASE: logger
MYSQL_USER: logger-user
MYSQL_PASSWORD: PandaCola-
ports:
- 3306:3306
adminer:
networks:
- logger_db
image: adminer
restart: always
ports:
- 8090:8090
networks:
logger_db: {}
Sorry the intentation is a bit messy
I would like to set the name of my logger-mysql in a the .env file of my webservice (the pandacola-logger) instead of his IP adress
here's the .env file
HOST=0.0.0.0
PORT=8060
NODE_ENV=development
APP_NAME=AdonisJs
APP_URL=http://${HOST}:${PORT}
CACHE_VIEWS=false
APP_KEY=Qs1GxZrmQf18YZ9V42FWUUnnxLfPetca
DB_CONNECTION=mysql
DB_HOST=0.0.0.0 <---- here's where I want to use my container's name
DB_PORT=3306
DB_USER=logger-user
DB_PASSWORD=PandaCola-
DB_DATABASE=logger
HASH_DRIVER=bcrypt
If you can tell me first, if it's possible, and then, how to do it, it would be lovely.
By default Compose sets up a single network for your app. Each container for a service joins the default network and is both reachable by other containers on that network, and discoverable by them at a hostname identical to the container name.
Reference
For Example:
version: '2.2'
services:
redis:
image: redis
container_name: cache
expose:
- 6379
app:
build: ./
volumes:
- ./:/var/www/app
ports:
- 7731:80
environment:
- REDIS_URL=redis://cache
- NODE_ENV=development
- PORT=80
command:
sh -c 'npm i && node server.js'
networks:
default:
external:
name: "tools"

Drone.IO – GitLab address with hosts file

I have a GitLab instance on a fixed internal IP, and configured the hosts file on the clients if a hostname which points to that IP.
But we are unable to make Drone work when using the hostname. We have Gitlab on port 80 and Drone on port 8000. It does work when it’s configured to the fixed ip:
Our compose file:
version: '2'
services:
gitlab:
image: 'gitlab/gitlab-ce:latest'
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://our.host.name.com'
gitlab_rails['gitlab_shell_ssh_port'] = 22
# Add any other gitlab.rb configuration here, each on its own line
ports:
- '80:80'
- '443:443'
- '22:22'
volumes:
- '/srv/gitlab/config:/etc/gitlab'
- '/srv/gitlab/logs:/var/log/gitlab'
- '/srv/gitlab/data:/var/opt/gitlab'
drone-server:
image: drone/drone:0.7.3
links:
- "gitlab:our.host.name.com"
ports:
- "8000:8000"
volumes:
- /home/drone:/var/lib/drone/
- /home/drone/cache:/var/lib/drone/cache/
- /home/foresight/keys:/var/lib/drone/keys
environment:
DRONE_OPEN: "true"
DRONE_SERVER_ADDR: ":8000"
DRONE_HOST: "http://our.host.name.com:8000"
DRONE_ADMIN: <redacted>
DRONE_GITLAB: "true"
DRONE_GITLAB_URL: "http://our.host.name.com"
DRONE_GITLAB_CLIENT: <redacted>
DRONE_GITLAB_SECRET: <redacted>
DRONE_SECRET: <redacted>
drone-agent:
image: drone/drone:0.7.3
command: agent
depends_on:
- drone-server
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
DRONE_SERVER: ws://drone-server:8000/ws/broker
DRONE_DEBUG: "true"
DRONE_SECRET: <redacted>
When i configure it this way, drone doesn’t seem to accept triggers from GitLab.
Naturally, i reset the drone cache, updated the callback url to use the domain name also, and re-activated the repositories.
i couldn’t find any log file for drone that provides insight on why the trigger fails.

Resources