How to connect to external FTP from NiFi running in docker container? - docker

I have:
NiFi running in docker container. I'm running NiFi via Docker Compose with the following config:
version: '3'
services:
nifi:
image: apache/nifi:latest
container_name: nifi
ports:
- "8443:8443"
volumes:
- ./database_repository:/opt/nifi/nifi-current/database_repository
- ./flowfile_repository:/opt/nifi/nifi-current/flowfile_repository
- ./content_repository:/opt/nifi/nifi-current/content_repository
- ./provenance_repository:/opt/nifi/nifi-current/provenance_repository
- ./state:/opt/nifi/nifi-current/state
- ./logs:/opt/nifi/nifi-current/logs
- ./conf:/opt/nifi/nifi-current/conf
restart: always
FTP server located on localhost (outside the container)
In the NiFi route i'm using a GetFTP processor which tries unsuccessfully to connect to localhost:21
I understand that the problem is that localhost is not available, because container is isolated. What and how to configure in the docker-compose.yml configuration to solve the problem?

Related

Docker Compose port forwarding works fine on MacOS but not on Linux

Having following docker compose script
version: '3.1'
services:
flowable-ui:
image: flowable/flowable-ui
container_name: flowable-ui
depends_on:
- flowable-db
environment:
- SERVER_PORT=8888
- SPRING_DATASOURCE_DRIVER-CLASS_NAME=org.postgresql.Driver
- SPRING_DATASOURCE_URL=jdbc:postgresql://flowable-db:5432/flowable
- SPRING_DATASOURCE_USERNAME=flowable
- SPRING_DATASOURCE_PASSWORD=flowable
ports:
- 80:8888
flowable-db:
image: postgres
container_name: flowable-db
environment:
- POSTGRES_PASSWORD=flowable
- POSTGRES_USER=flowable
- POSTGRES_DB=flowable
ports:
- 5432:5432
command: postgres
I can start with docker-compose up -d flowable image and it is accessible at http://localhost/flowable-ui in my browser.
Doing exactly the same on my Linux machine causes http://localhost/flowable-ui is not loading, I see that there is something there because the browser tries to access it, but it doesn't happen and I get timeout.
Do I have to set up something additionally on the Linux machine?
You're trying to port-forward from 8888 from your container to 80 to your host. On Linux, you'd need elevated permissions to open ports 1-1024.
Try a port >1024. For example
services:
flowable-ui:
...
ports:
- 8888:8888
and then access your app on http://localhost:8888.

Trying to change default Jenkins port on a Docker container

As part of a school challenge I need to run a Jenkins environment using Docker on port 7070:9090.
I'm trying to change the default access port for Jenkins (8080) on a Docker container unsuccessfully.
Here's my code:
version: '3'
services:
jenkins:
container_name: jenkins
image: jenkins-image
ports:
- "7070:8080"
volumes:
- "jenkins_home:/var/jenkins_home"
- "/var/run/docker.sock:/var/run/docker.sock"
I managed to change the localhost to 7070, but not the default access port from 8080.
All the tutorials I've found online only explain how to change the localhost.
Any advice on how to change the port 8080 and still manage to have Jenkins running?
Access port is related with Docker instead of Jenkins. The syntax should be like this HOST:CONTAINER if the Jenkins is running at 7070 in your container following code needs to work for you.
version: '3'
services:
jenkins:
container_name: jenkins
image: jenkins-image
ports:
- "8080:7070"
volumes:
- "jenkins_home:/var/jenkins_home"
- "/var/run/docker.sock:/var/run/docker.sock"

Unable to connecto to docker container

Hi i'm start a docker container using docker-compose, but when i try to use localhost to connect I can't connect. Here is the docker-compose i'm using:
version: '3.3'
services:
standalone:
image: apachepulsar/pulsar
expose:
- 8080
- 6650
environment:
- PULSAR_MEM=" -Xms512m -Xmx512m -XX:MaxDirectMemorySize=1g"
command: >
/bin/bash -c
"bin/apply-config-from-env.py conf/standalone.conf
&& bin/pulsar standalone"
Im using windows 10
Be aware that expose, as the documentation suggest:
Expose ports without publishing them to the host machine - they’ll only be accessible to linked services. Only the internal port can be specified.
My guess is that you instead want to publish them and let them be available to the host. To do so:
services:
standalone:
image: apachepulsar/pulsar
ports:
- "8080:8080"
- "6650:6650"

Accesing another service using its url from inside the docker-compose network

I am hosting 3 services using docker-compose.
version: '3.3'
services:
service-a:
container_name: service-a
network_mode: default
ports:
- 8001:8001
- 8080:8080
service-b:
container_name: service-b
network_mode: default
ports:
- 8180:8080
links:
- service-a:srv_a
service-api:
container_name: service-api
environment:
- SERVER_URL=http://localhost:8180/myserver
- 8001:8001
links:
- service-b: srv_b
However the service-api which is a spring boot application can't access the
service-b despite the link.
I can do that when using the browser.
What can I do to investigate the reasons for the lack of connectivity?
Should the link be somehow used in the server_url variable?
Each Docker container has it's own IP address. From the service-api container perspective, localhost resolve to its own IP address.
Docker-compose provides your containers with the ability to resolve other containers IP addresses from the docker compose service names.
Try:
service-api:
environment:
- SERVER_URL=http://service-b:8080/myserver
note that you need to connect to the container internal port (8080) and not the matching port published on the docker host (8180).

Aspnet core application is not running after docker host or container restart

I'm running containers with restart policy as always through docker-compose, it has two images RabbitMq & AspNetCore,it all works fine for the first time.
when I restart the host or docker containers then RabbitMq is running fine and accessible through localhost:8080 even after restarting, but aspnet core project container is running but I can't access through internal and external ( localhost:5001/api/home/get) ports.
Docker compose
version: '3.4'
services:
aspnetcoreenvironmentvariables.api:
image: aspnetcoreenvironmentvariables
build:
context: .
dockerfile: AspNetCoreEnvironmentVariables.API/Dockerfile
restart: always
depends_on:
- rabbitmq
rabbitmq:
image: rabbitmq:3-management
restart: always
Docker compose override
version: '3.4'
services:
aspnetcoreenvironmentvariables.api:
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ConnectionStrings__DefaultConnection="connection"
ports:
- "5001:80"
rabbitmq:
ports:
- "8080:15672"
Below is error from docker

Resources