Why can't I access my web app from a remote container? - docker
I have looked through past answers since this is a common question but no solution seems to work for me.
I have a Springboot Java app and a postgresql database, each in their own container. Both containers run on a remote headless server on a local network. My remote server's physical IP address is 192.168.1.200. When I enter: 'http://192.168.1.200:8080' in my browser from another machine I get a 'unable to connect' response.
Here is my Docker-compose file:
version: "3.3"
services:
db:
image: postgres
environment:
POSTGRES_PASSWORD: aaa
volumes:
- /var/lib/postgresql/data
ports:
- "5432:5432"
networks:
- nat
web:
image: email-viewer
ports:
- "192.168.1.200:8080:80"
depends_on:
- db
networks:
- nat
networks:
nat:
external:
name: nat
Here is the output when I run docker-compose up:
Recreating email-viewer_db_1 ... done
Recreating email-viewer_web_1 ... done
Attaching to email-viewer_db_1, email-viewer_web_1
db_1 |
db_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1 |
db_1 | 2022-05-06 16:13:24.300 UTC [1] LOG: starting PostgreSQL 14.2 (Debian 14.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
db_1 | 2022-05-06 16:13:24.300 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2022-05-06 16:13:24.300 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2022-05-06 16:13:24.305 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2022-05-06 16:13:24.311 UTC [27] LOG: database system was shut down at 2022-05-06 13:54:07 UTC
db_1 | 2022-05-06 16:13:24.319 UTC [1] LOG: database system is ready to accept connections
web_1 |
web_1 | . ____ _ __ _ _
web_1 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
web_1 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
web_1 | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
web_1 | ' |____| .__|_| |_|_| |_\__, | / / / /
web_1 | =========|_|==============|___/=/_/_/_/
web_1 | :: Spring Boot :: (v2.6.5)
web_1 |
web_1 | 2022-05-06 16:13:25.487 INFO 1 --- [ main] c.a.emailviewer.EmailViewerApplication : Starting EmailViewerApplication v0.0.1-SNAPSHOT using Java 17.0.2 on 1a13d69d117d with PID 1 (/app/email-viewer-0.0.1-SNAPSHOT.jar started by root in /app)
web_1 | 2022-05-06 16:13:25.490 INFO 1 --- [ main] c.a.emailviewer.EmailViewerApplication : No active profile set, falling back to 1 default profile: "default"
web_1 | 2022-05-06 16:13:26.137 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
web_1 | 2022-05-06 16:13:26.184 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 38 ms. Found 1 JPA repository interfaces.
web_1 | 2022-05-06 16:13:26.764 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
web_1 | 2022-05-06 16:13:26.774 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
web_1 | 2022-05-06 16:13:26.775 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.60]
web_1 | 2022-05-06 16:13:26.843 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
web_1 | 2022-05-06 16:13:26.843 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1297 ms
web_1 | 2022-05-06 16:13:27.031 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
web_1 | 2022-05-06 16:13:27.077 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.7.Final
web_1 | 2022-05-06 16:13:27.222 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
web_1 | 2022-05-06 16:13:27.313 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
web_1 | 2022-05-06 16:13:27.506 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
web_1 | 2022-05-06 16:13:27.539 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
web_1 | 2022-05-06 16:13:28.034 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
web_1 | 2022-05-06 16:13:28.042 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
web_1 | 2022-05-06 16:13:28.330 WARN 1 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
web_1 | 2022-05-06 16:13:28.663 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
web_1 | 2022-05-06 16:13:28.672 INFO 1 --- [ main] c.a.emailviewer.EmailViewerApplication : Started EmailViewerApplication in 3.615 seconds (JVM running for 4.024)
It turns out that the embedded tomcat server in spring boot uses port 8080 by default and would require 192.168.1.200:8080:8080 instead of 192.168.1.200:8080:80
Related
Sonarscanner cannot reach sonarqube server using docker-compose
I have just created my docker-compose file, trying to run sonarqube server along side posgres and sonarscanner. The sonarqube server and the database can connect however my sonarscanner cannot reach the sonarqube server. This is my docker-compose file: version: "3" services: sonarqube: image: sonarqube build: . expose: - 9000 ports: - "127.0.0.1:9000:9000" networks: - sonarnet environment: - sonar.jdbc.url=jdbc:postgresql://postgres:5432/sonar - sonar.jdbc.username=sonar - sonar.jdbc.password=sonar volumes: - sonarqube_conf:/opt/sonarqube/conf - sonarqube_data:/opt/sonarqube/data - sonarqube_extensions:/opt/sonarqube/extensions - sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins postgres: image: postgres build: . networks: - sonarnet ports: - "5432:5432" environment: - POSTGRES_USER=sonar - POSTGRES_PASSWORD=sonar volumes: - postgresql:/var/lib/postgresql - postgresql_data:/var/lib/postgresql/data sonarscanner: image: newtmitch/sonar-scanner networks: - sonarnet depends_on: - sonarqube volumes: - ./:/usr/src networks: sonarnet: volumes: sonarqube_conf: sonarqube_data: sonarqube_extensions: sonarqube_bundled-plugins: postgresql: postgresql_data: This is my sonar-project.propeties file: # must be unique in a given SonarQube instance sonar.projectKey=toh-token # --- optional properties --- #defaults to project key #sonar.projectName=toh # defaults to 'not provided' #sonar.projectVersion=1.0 # Path is relative to the sonar-project.properties file. Defaults to . #sonar.sources=$HOME/.solo/angular/toh # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 My sonar-project.properties is located in the same directory as the docker-compose file. This is what happens whenever I start the services: Attaching to sonarqube-postgres-1, sonarqube-sonarqube-1, sonarqube-sonarscanner-1 sonarqube-sonarqube-1 | Dropping Privileges sonarqube-postgres-1 | sonarqube-postgres-1 | PostgreSQL Database directory appears to contain a database; Skipping initialization sonarqube-postgres-1 | sonarqube-postgres-1 | 2022-06-12 20:59:39.522 UTC [1] LOG: starting PostgreSQL 14.3 (Debian 14.3-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit sonarqube-postgres-1 | 2022-06-12 20:59:39.523 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 sonarqube-postgres-1 | 2022-06-12 20:59:39.523 UTC [1] LOG: listening on IPv6 address "::", port 5432 sonarqube-postgres-1 | 2022-06-12 20:59:39.525 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" sonarqube-postgres-1 | 2022-06-12 20:59:39.533 UTC [26] LOG: database system was shut down at 2022-06-12 20:57:58 UTC sonarqube-postgres-1 | 2022-06-12 20:59:39.542 UTC [1] LOG: database system is ready to accept connections sonarqube-sonarscanner-1 | INFO: Scanner configuration file: /usr/lib/sonar-scanner/conf/sonar-scanner.properties sonarqube-sonarscanner-1 | INFO: Project root configuration file: /usr/src/sonar-project.properties sonarqube-sonarscanner-1 | INFO: SonarScanner 4.5.0.2216 sonarqube-sonarscanner-1 | INFO: Java 12-ea Oracle Corporation (64-bit) sonarqube-sonarscanner-1 | INFO: Linux 5.10.117-1-MANJARO amd64 sonarqube-sonarscanner-1 | INFO: User cache: /root/.sonar/cache sonarqube-sonarqube-1 | 2022.06.12 20:59:40 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp sonarqube-sonarqube-1 | 2022.06.12 20:59:40 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:41087] sonarqube-sonarscanner-1 | ERROR: SonarQube server [http://sonarqube:9000] can not be reached sonarqube-sonarscanner-1 | INFO: ------------------------------------------------------------------------ sonarqube-sonarscanner-1 | INFO: EXECUTION FAILURE sonarqube-sonarscanner-1 | INFO: ------------------------------------------------------------------------ sonarqube-sonarscanner-1 | INFO: Total time: 0.802s sonarqube-sonarscanner-1 | INFO: Final Memory: 3M/20M sonarqube-sonarscanner-1 | INFO: ------------------------------------------------------------------------ sonarqube-sonarscanner-1 | ERROR: Error during SonarScanner execution sonarqube-sonarscanner-1 | org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85) sonarqube-sonarscanner-1 | at java.base/java.security.AccessController.doPrivileged(AccessController.java:310) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.cli.Main.execute(Main.java:73) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.cli.Main.main(Main.java:61) sonarqube-sonarscanner-1 | Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76) sonarqube-sonarscanner-1 | ... 7 more sonarqube-sonarscanner-1 | Caused by: java.net.ConnectException: Failed to connect to sonarqube/172.30.0.2:9000 sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectSocket(RealConnection.java:265) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connect(RealConnection.java:183) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.Transmitter.newExchange(Transmitter.java:169) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:221) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:81) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:114) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:99) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:39) sonarqube-sonarscanner-1 | ... 10 more sonarqube-sonarscanner-1 | Caused by: java.net.ConnectException: Connection refused (Connection refused) sonarqube-sonarscanner-1 | at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) sonarqube-sonarscanner-1 | at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) sonarqube-sonarscanner-1 | at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242) sonarqube-sonarscanner-1 | at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224) sonarqube-sonarscanner-1 | at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403) sonarqube-sonarscanner-1 | at java.base/java.net.Socket.connect(Socket.java:591) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.platform.Platform.connectSocket(Platform.java:130) sonarqube-sonarscanner-1 | at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectSocket(RealConnection.java:263) sonarqube-sonarscanner-1 | ... 31 more sonarqube-sonarscanner-1 | ERROR: sonarqube-sonarscanner-1 | ERROR: Re-run SonarScanner using the -X switch to enable full debug logging. Is there something I am doing wrong?
As #Hans Killian said, the issue was with the scanner trying to connect to the server before the server was up and running. I fixed it by just adding the following in the service of the scanner: command: ["sh", "-c", "sleep 60 && sonar-scanner && -Dsonar.projectBaseDir=/usr/src]. This allows the scanner to be suspended until the server is up and running I then added the following credentials in the sonar.project.properties file: sonar.login=admin sonar.password=admin
Rabbitmq on docker: Application mnesia exited with reason: stopped
I'm trying to launch Rabbitmq with docker-compose alongside DRF and Celery. Here's my docker-compose file. Everything else works fine, except for rabbitmq: version: '3.7' services: drf: build: ./drf entrypoint: ["/bin/sh","-c"] command: - | python manage.py migrate python manage.py runserver 0.0.0.0:8000 volumes: - ./drf/:/usr/src/drf/ ports: - 8000:8000 env_file: - ./.env.dev depends_on: - db db: image: postgres:12.0-alpine volumes: - postgres_data:/var/lib/postgresql/data/ environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres - POSTGRES_DB=base_test redis: image: redis:alpine volumes: - redis:/data ports: - "6379:6379" depends_on: - drf rabbitmq: image: rabbitmq:3-management-alpine container_name: 'rabbitmq' ports: - 5672:5672 - 15672:15672 volumes: - ~/.docker-conf/rabbitmq/data/:/var/lib/rabbitmq/ - ~/.docker-conf/rabbitmq/log/:/var/log/rabbitmq networks: - net_1 celery_worker: command: sh -c "wait-for redis:3000 && wait-for drf:8000 -- celery -A base-test worker -l info" depends_on: - drf - db - redis deploy: replicas: 2 restart_policy: condition: on-failure resources: limits: cpus: '0.50' memory: 50M reservations: cpus: '0.25' memory: 20M hostname: celery_worker image: app-image networks: - net_1 restart: on-failure celery_beat: command: sh -c "wait-for redis:3000 && wait-for drf:8000 -- celery -A mysite beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler" depends_on: - drf - db - redis hostname: celery_beat image: app-image networks: - net_1 restart: on-failure networks: net_1: driver: bridge volumes: postgres_data: redis: And here's what happens when I launch it. Can someone please help me find the problem? I can't even follow the instruction and read the generated dump file because rabbitmq container exits after the error. rabbitmq | Starting broker...2021-04-05 16:49:58.330 [info] <0.273.0> rabbitmq | node : rabbit#0e652f57b1b3 rabbitmq | home dir : /var/lib/rabbitmq rabbitmq | config file(s) : /etc/rabbitmq/rabbitmq.conf rabbitmq | cookie hash : ZPam/SOKy2dEd/3yt0OlaA== rabbitmq | log(s) : <stdout> rabbitmq | database dir : /var/lib/rabbitmq/mnesia/rabbit#0e652f57b1b3 rabbitmq | 2021-04-05 16:50:09.542 [info] <0.273.0> Feature flags: list of feature flags found: rabbitmq | 2021-04-05 16:50:09.542 [info] <0.273.0> Feature flags: [x] drop_unroutable_metric rabbitmq | 2021-04-05 16:50:09.542 [info] <0.273.0> Feature flags: [x] empty_basic_get_metric rabbitmq | 2021-04-05 16:50:09.542 [info] <0.273.0> Feature flags: [x] implicit_default_bindings rabbitmq | 2021-04-05 16:50:09.542 [info] <0.273.0> Feature flags: [x] maintenance_mode_status rabbitmq | 2021-04-05 16:50:09.542 [info] <0.273.0> Feature flags: [ ] quorum_queue rabbitmq | 2021-04-05 16:50:09.543 [info] <0.273.0> Feature flags: [ ] user_limits rabbitmq | 2021-04-05 16:50:09.545 [info] <0.273.0> Feature flags: [ ] virtual_host_metadata rabbitmq | 2021-04-05 16:50:09.546 [info] <0.273.0> Feature flags: feature flag states written to disk: yes rabbitmq | 2021-04-05 16:50:10.844 [info] <0.273.0> Running boot step pre_boot defined by app rabbit rabbitmq | 2021-04-05 16:50:10.845 [info] <0.273.0> Running boot step rabbit_core_metrics defined by app rabbit rabbitmq | 2021-04-05 16:50:10.846 [info] <0.273.0> Running boot step rabbit_alarm defined by app rabbit rabbitmq | 2021-04-05 16:50:10.854 [info] <0.414.0> Memory high watermark set to 2509 MiB (2631391641 bytes) of 6273 MiB (6578479104 bytes) total rabbitmq | 2021-04-05 16:50:10.864 [info] <0.416.0> Enabling free disk space monitoring rabbitmq | 2021-04-05 16:50:10.864 [info] <0.416.0> Disk free limit set to 50MB rabbitmq | 2021-04-05 16:50:10.872 [info] <0.273.0> Running boot step code_server_cache defined by app rabbit rabbitmq | 2021-04-05 16:50:10.872 [info] <0.273.0> Running boot step file_handle_cache defined by app rabbit rabbitmq | 2021-04-05 16:50:10.872 [info] <0.419.0> Limiting to approx 1048479 file handles (943629 sockets) rabbitmq | 2021-04-05 16:50:10.873 [info] <0.420.0> FHC read buffering: OFF rabbitmq | 2021-04-05 16:50:10.873 [info] <0.420.0> FHC write buffering: ON rabbitmq | 2021-04-05 16:50:10.874 [info] <0.273.0> Running boot step worker_pool defined by app rabbit rabbitmq | 2021-04-05 16:50:10.874 [info] <0.372.0> Will use 4 processes for default worker pool rabbitmq | 2021-04-05 16:50:10.874 [info] <0.372.0> Starting worker pool 'worker_pool' with 4 processes in it rabbitmq | 2021-04-05 16:50:10.876 [info] <0.273.0> Running boot step database defined by app rabbit rabbitmq | 2021-04-05 16:50:10.899 [info] <0.273.0> Waiting for Mnesia tables for 30000 ms, 9 retries left rabbitmq | 2021-04-05 16:50:10.900 [info] <0.273.0> Successfully synced tables from a peer rabbitmq | 2021-04-05 16:50:10.908 [info] <0.44.0> Application mnesia exited with reason: stopped rabbitmq | rabbitmq | 2021-04-05 16:50:10.908 [info] <0.44.0> Application mnesia exited with reason: stopped rabbitmq | 2021-04-05 16:50:10.908 [error] <0.273.0> rabbitmq | 2021-04-05 16:50:10.908 [error] <0.273.0> BOOT FAILED rabbitmq | BOOT FAILED rabbitmq | =========== rabbitmq | Error during startup: {error, rabbitmq | 2021-04-05 16:50:10.909 [error] <0.273.0> =========== rabbitmq | 2021-04-05 16:50:10.909 [error] <0.273.0> Error during startup: {error, rabbitmq | 2021-04-05 16:50:10.909 [error] <0.273.0> {schema_integrity_check_failed, rabbitmq | {schema_integrity_check_failed, rabbitmq | [{table_attributes_mismatch,rabbit_queue, rabbitmq | 2021-04-05 16:50:10.910 [error] <0.273.0> [{table_attributes_mismatch,rabbit_queue, rabbitmq | 2021-04-05 16:50:10.910 [error] <0.273.0> [name,durable,auto_delete,exclusive_owner, rabbitmq | 2021-04-05 16:50:10.911 [error] <0.273.0> arguments,pid,slave_pids,sync_slave_pids, rabbitmq | 2021-04-05 16:50:10.911 [error] <0.273.0> recoverable_slaves,policy,operator_policy, rabbitmq | [name,durable,auto_delete,exclusive_owner, rabbitmq | arguments,pid,slave_pids,sync_slave_pids, rabbitmq | 2021-04-05 16:50:10.911 [error] <0.273.0> gm_pids,decorators,state,policy_version, rabbitmq | 2021-04-05 16:50:10.911 [error] <0.273.0> slave_pids_pending_shutdown,vhost,options], rabbitmq | 2021-04-05 16:50:10.912 [error] <0.273.0> [name,durable,auto_delete,exclusive_owner, rabbitmq | 2021-04-05 16:50:10.912 [error] <0.273.0> arguments,pid,slave_pids,sync_slave_pids, rabbitmq | 2021-04-05 16:50:10.913 [error] <0.273.0> recoverable_slaves,policy,operator_policy, rabbitmq | 2021-04-05 16:50:10.913 [error] <0.273.0> gm_pids,decorators,state,policy_version, rabbitmq | 2021-04-05 16:50:10.913 [error] <0.273.0> slave_pids_pending_shutdown,vhost,options, rabbitmq | recoverable_slaves,policy,operator_policy, rabbitmq | gm_pids,decorators,state,policy_version, rabbitmq | slave_pids_pending_shutdown,vhost,options], rabbitmq | [name,durable,auto_delete,exclusive_owner, rabbitmq | arguments,pid,slave_pids,sync_slave_pids, rabbitmq | recoverable_slaves,policy,operator_policy, rabbitmq | gm_pids,decorators,state,policy_version, rabbitmq | slave_pids_pending_shutdown,vhost,options, rabbitmq | type,type_state]}]}} rabbitmq | 2021-04-05 16:50:10.914 [error] <0.273.0> type,type_state]}]}} rabbitmq | 2021-04-05 16:50:10.916 [error] <0.273.0> rabbitmq | rabbitmq | 2021-04-05 16:50:11.924 [info] <0.272.0> [{initial_call,{application_master,init,['Argument__1','Argument__2','Argument__3','Argument__4']}},{pid,<0.272.0>},{registered_name,[]},{error_info ,{exit,{{schema_integrity_check_failed,[{table_attributes_mismatch,rabbit_queue,[name,durable,auto_delete,exclusive_owner,arguments,pid,slave_pids,sync_slave_pids,recoverable_slaves,policy,operator_policy,gm_ pids,decorators,state,policy_version,slave_pids_pending_shutdown,vhost,options],[name,durable,auto_delete,exclusive_owner,arguments,pid,slave_pids,sync_slave_pids,recoverable_slaves,policy,operator_policy,gm_ pids,decorators,state,policy_version,slave_pids_pending_shutdown,vhost,options,type,type_state]}]},{rabbit,start,[normal,[]]}},[{application_master,init,4,[{file,"application_master.erl"},{line,138}]},{proc_l ib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}},{ancestors,[<0.271.0>]},{message_queue_len,1},{messages,[{'EXIT',<0.273.0>,normal}]},{links,[<0.271.0>,<0.44.0>]},{dictionary,[]},{trap_exit,true},{ status,running},{heap_size,610},{stack_size,28},{reductions,534}], [] rabbitmq | 2021-04-05 16:50:11.924 [error] <0.272.0> CRASH REPORT Process <0.272.0> with 0 neighbours exited with reason: {{schema_integrity_check_failed,[{table_attributes_mismatch,rabbit_queue,[name ,durable,auto_delete,exclusive_owner,arguments,pid,slave_pids,sync_slave_pids,recoverable_slaves,policy,operator_policy,gm_pids,decorators,state,policy_version,slave_pids_pending_shutdown,vhost,options],[name ,durable,auto_delete,exclusive_owner,arguments,pid,slave_pids,sync_slave_pids,recoverable_slaves,policy,operator_policy,gm_pids,decorators,state,policy_version,slave_pids_pending_shutdown,vhost,options,type,t ype_state]}]},...} in application_master:init/4 line 138 rabbitmq | 2021-04-05 16:50:11.924 [info] <0.44.0> Application rabbit exited with reason: {{schema_integrity_check_failed,[{table_attributes_mismatch,rabbit_queue,[name,durable,auto_delete,exclusive_o wner,arguments,pid,slave_pids,sync_slave_pids,recoverable_slaves,policy,operator_policy,gm_pids,decorators,state,policy_version,slave_pids_pending_shutdown,vhost,options],[name,durable,auto_delete,exclusive_o wner,arguments,pid,slave_pids,sync_slave_pids,recoverable_slaves,policy,operator_policy,gm_pids,decorators,state,policy_version,slave_pids_pending_shutdown,vhost,options,type,type_state]}]},...} rabbitmq | 2021-04-05 16:50:11.925 [info] <0.44.0> Application rabbit exited with reason: {{schema_integrity_check_failed,[{table_attributes_mismatch,rabbit_queue,[name,durable,auto_delete,exclusive_o wner,arguments,pid,slave_pids,sync_slave_pids,recoverable_slaves,policy,operator_policy,gm_pids,decorators,state,policy_version,slave_pids_pending_shutdown,vhost,options],[name,durable,auto_delete,exclusive_o wner,arguments,pid,slave_pids,sync_slave_pids,recoverable_slaves,policy,operator_policy,gm_pids,decorators,state,policy_version,slave_pids_pending_shutdown,vhost,options,type,type_state]}]},...} rabbitmq | {"Kernel pid terminated",application_controller,"{application_start_failure,rabbit,{{schema_integrity_check_failed,[{table_attributes_mismatch,rabbit_queue,[name,durable,auto_delete,exclusi ve_owner,arguments,pid,slave_pids,sync_slave_pids,recoverable_slaves,policy,operator_policy,gm_pids,decorators,state,policy_version,slave_pids_pending_shutdown,vhost,options],[name,durable,auto_delete,exclusi ve_owner,arguments,pid,slave_pids,sync_slave_pids,recoverable_slaves,policy,operator_policy,gm_pids,decorators,state,policy_version,slave_pids_pending_shutdown,vhost,options,type,type_state]}]},{rabbit,start, [normal,[]]}}}"} rabbitmq | Kernel pid terminated (application_controller) ({application_start_failure,rabbit,{{schema_integrity_check_failed,[{table_attributes_mismatch,rabbit_queue,[name,durable,auto_delete,exclusiv e_owner,arg rabbitmq | rabbitmq | Crash dump is being written to: /var/log/rabbitmq/erl_crash.dump...done rabbitmq exited with code 0
I've managed to make it work by removing container_name and volumes from rabbitmq section of docker-compose file. Still would be nice to have an explanation of this behavior.
docker-entrypoint.sh is being ignored
The console logs /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/tables during the build of the Docker container (see full log below). What could be the case for this considering I have the following code: File overview users.sql BEGIN TRANSACTION; CREATE TABLE users ( id serial PRIMARY KEY, name VARCHAR(100), email text UNIQUE NOT NULL, entries BEGINT DEFAULT 0, joined TIMESTAMP NOT NULL ); COMMIT; deploy_schemas.sql -- Deploy fresh database tables \i '/docker-entrypoint-initdb.d/tables/users.sql' \i '/docker-entrypoint-initdb.d/tables/login.sql' Dockerfile (in postgres folder) FROM postgres:12.2 ADD /tables/ /docker-entrypoint-initdb.d/tables/ ADD deploy_schemas.sql /docker-entrypoint-initdb.d/tables/ **docker-compose.yml** version: "3.3" services: # Backend API smart-brain-app: container_name: backend # image: mode:14.2.0 build: ./ command: npm start working_dir: /usr/src/smart-brain-api environment: POSTGRES_URI: postgres://postgres:1212#postgres:5431/smart-brain-api-db links: - postgres ports: - "3000:3000" volumes: - ./:/usr/src/smart-brain-api # Postgres postgres: build: ./postgres environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: 1212 POSTGRES_DB: smart-brain-api-db POSTGRES_HOST: postgres ports: - "5431:5432" Dockerfile FROM node:14.2.0 WORKDIR /usr/src/smart-brain-api COPY ./ ./ RUN npm install | npm audit fix CMD ["/bin/bash"] Complete Log Creating smart-brain-api_postgres_1 ... done Creating backend ... done Attaching to smart-brain-api_postgres_1, backend postgres_1 | The files belonging to this database system will be owned by user "postgres". postgres_1 | This user must also own the server process. postgres_1 | postgres_1 | The database cluster will be initialized with locale "en_US.utf8". postgres_1 | The default database encoding has accordingly been set to "UTF8". postgres_1 | The default text search configuration will be set to "english". postgres_1 | postgres_1 | Data page checksums are disabled. postgres_1 | postgres_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok postgres_1 | creating subdirectories ... ok postgres_1 | selecting dynamic shared memory implementation ... posix postgres_1 | selecting default max_connections ... 100 postgres_1 | selecting default shared_buffers ... 128MB postgres_1 | selecting default time zone ... Etc/UTC postgres_1 | creating configuration files ... ok postgres_1 | running bootstrap script ... ok backend | backend | > node#1.0.0 start /usr/src/smart-brain-api backend | > npx nodemon server.js backend | postgres_1 | performing post-bootstrap initialization ... ok postgres_1 | syncing data to disk ... ok postgres_1 | postgres_1 | initdb: warning: enabling "trust" authentication for local connections postgres_1 | You can change this by editing pg_hba.conf or using the option -A, or postgres_1 | --auth-local and --auth-host, the next time you run initdb. postgres_1 | postgres_1 | Success. You can now start the database server using: postgres_1 | postgres_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start postgres_1 | postgres_1 | waiting for server to start....2020-05-10 01:31:31.548 UTC [46] LOG: starting PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit postgres_1 | 2020-05-10 01:31:31.549 UTC [46] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" postgres_1 | 2020-05-10 01:31:31.565 UTC [47] LOG: database system was shut down at 2020-05-10 01:31:31 UTC postgres_1 | 2020-05-10 01:31:31.569 UTC [46] LOG: database system is ready to accept connections postgres_1 | done postgres_1 | server started postgres_1 | CREATE DATABASE postgres_1 | postgres_1 | postgres_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/tables postgres_1 | postgres_1 | 2020-05-10 01:31:31.772 UTC [46] LOG: received fast shutdown request postgres_1 | waiting for server to shut down....2020-05-10 01:31:31.774 UTC [46] LOG: aborting any active transactions postgres_1 | 2020-05-10 01:31:31.775 UTC [46] LOG: background worker "logical replication launcher" (PID 53) exited with exit code 1 postgres_1 | 2020-05-10 01:31:31.778 UTC [48] LOG: shutting down postgres_1 | 2020-05-10 01:31:31.791 UTC [46] LOG: database system is shut down postgres_1 | done postgres_1 | server stopped postgres_1 | postgres_1 | PostgreSQL init process complete; ready for start up. postgres_1 | postgres_1 | 2020-05-10 01:31:31.884 UTC [1] LOG: starting PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit postgres_1 | 2020-05-10 01:31:31.884 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 postgres_1 | 2020-05-10 01:31:31.884 UTC [1] LOG: listening on IPv6 address "::", port 5432 postgres_1 | 2020-05-10 01:31:31.894 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" postgres_1 | 2020-05-10 01:31:31.910 UTC [64] LOG: database system was shut down at 2020-05-10 01:31:31 UTC postgres_1 | 2020-05-10 01:31:31.914 UTC [1] LOG: database system is ready to accept connections
docker-flink not showing all log statements
I am using 2 docker flink images with AMIDST and the following sample code. AMIDST is a probabilistic graphical model framework which supports Flink. One image is running as JobManager the other as TaskManager. JM is reachable via DNS and I provide my own log4j.properties based on the startup script in bin/flink-console.sh used by these images. public class ParallelMLExample { private static final Logger LOG = LoggerFactory.getLogger(ParallelMLExample.class); public static void main(String[] args) throws Exception { final ExecutionEnvironment env; //Set-up Flink session env = ExecutionEnvironment.getExecutionEnvironment(); env.getConfig().disableSysoutLogging(); //generate a random dataset DataFlink<DataInstance> dataFlink = new DataSetGenerator().generate(env, 1234, 1000, 5, 0); //Creates a DAG with the NaiveBayes structure for the random dataset DAG dag = DAGGenerator.getNaiveBayesStructure(dataFlink.getAttributes(), "DiscreteVar4"); LOG.info(dag.toString()); //Create the Learner object ParameterLearningAlgorithm learningAlgorithmFlink = new ParallelMaximumLikelihood(); //Learning parameters learningAlgorithmFlink.setBatchSize(10); learningAlgorithmFlink.setDAG(dag); //Initialize the learning process learningAlgorithmFlink.initLearning(); //Learn from the flink data LOG.info("########## BEFORE UPDATEMODEL ##########"); learningAlgorithmFlink.updateModel(dataFlink); LOG.info("########## AFTER UPDATEMODEL ##########"); //Print the learnt Bayes Net BayesianNetwork bn = learningAlgorithmFlink.getLearntBayesianNetwork(); LOG.info(bn.toString()); } } The problem is that I only see LOG.info() entries up until the updateModel call. After that silence. If I comment out this call, I can see the other entries. I am silencing Flink entries on purpose here. Creating flink_jobmanager_1 ... done Creating flink_jobmanager_1 ... Creating flink_taskmanager_1 ... done Attaching to flink_jobmanager_1, flink_taskmanager_1 jobmanager_1 | Starting Job Manager jobmanager_1 | config file: taskmanager_1 | Starting Task Manager jobmanager_1 | jobmanager.rpc.address: jobmanager taskmanager_1 | config file: jobmanager_1 | jobmanager.rpc.port: 6123 jobmanager_1 | jobmanager.heap.mb: 1024 taskmanager_1 | jobmanager.rpc.address: jobmanager jobmanager_1 | taskmanager.heap.mb: 1024 taskmanager_1 | jobmanager.rpc.port: 6123 jobmanager_1 | taskmanager.numberOfTaskSlots: 1 taskmanager_1 | jobmanager.heap.mb: 1024 jobmanager_1 | taskmanager.memory.preallocate: false taskmanager_1 | taskmanager.heap.mb: 1024 jobmanager_1 | parallelism.default: 1 taskmanager_1 | taskmanager.numberOfTaskSlots: 2 jobmanager_1 | web.port: 8081 taskmanager_1 | taskmanager.memory.preallocate: false jobmanager_1 | blob.server.port: 6124 taskmanager_1 | parallelism.default: 1 jobmanager_1 | query.server.port: 6125 taskmanager_1 | web.port: 8081 jobmanager_1 | Starting jobmanager as a console application on host c16d9156ff68. taskmanager_1 | blob.server.port: 6124 taskmanager_1 | query.server.port: 6125 taskmanager_1 | Starting taskmanager as a console application on host 76c78378d35c. jobmanager_1 | 2018-02-18 15:31:42,809 INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started taskmanager_1 | 2018-02-18 15:31:43,897 INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started jobmanager_1 | 2018-02-18 15:32:18,667 INFO com.ness.ParallelMLExample - DAG jobmanager_1 | DiscreteVar0 has 1 parent(s): {DiscreteVar4} jobmanager_1 | DiscreteVar1 has 1 parent(s): {DiscreteVar4} jobmanager_1 | DiscreteVar2 has 1 parent(s): {DiscreteVar4} jobmanager_1 | DiscreteVar3 has 1 parent(s): {DiscreteVar4} jobmanager_1 | DiscreteVar4 has 0 parent(s): {} jobmanager_1 | jobmanager_1 | 2018-02-18 15:32:18,679 INFO com.ness.ParallelMLExample - ########## BEFORE UPDATEMODEL ########## The updateModel method starts with a new Configuration() then retrieves the data set. It then runs a map, reduce and collect against the supplied data set but does not seem to be messing with root loggers... What am I missing?
Docker Container Failed to Run
The Dockerfile for my application is as follows # Tells the Docker which base image to start. FROM node # Adds files from the host file system into the Docker container. ADD . /app # Sets the current working directory for subsequent instructions WORKDIR /app RUN npm install RUN npm install -g bower RUN bower install --allow-root RUN npm install -g nodemon #expose a port to allow external access EXPOSE 9000 9030 35729 # Start mean application CMD ["nodemon", "server.js"] The docker-compose.yml file is as follows web: build: . links: - db ports: - "9000:9000" - "9030:9030" - "35729:35729" db: image: mongo:latest ports: - "27017:27017" And the error generated while running is as follows:- web_1 | [nodemon] 1.11.0 web_1 | [nodemon] to restart at any time, enter `rs` web_1 | [nodemon] watching: *.* web_1 | [nodemon] starting `node server.js` web_1 | Server running at http://127.0.0.1:9000 web_1 | Server running at https://127.0.0.1:9030 web_1 | web_1 | /app/node_modules/mongodb/lib/server.js:261 web_1 | process.nextTick(function() { throw err; }) web_1 | ^ web_1 | MongoError: failed to connect to server [localhost:27017] on first connect web_1 | at Pool.<anonymous> (/app/node_modules/mongodb-core/lib/topologies/server.js:313:35) web_1 | at emitOne (events.js:96:13) web_1 | at Pool.emit (events.js:188:7) web_1 | at Connection.<anonymous> (/app/node_modules/mongodb-core/lib/connection/pool.js:271:12) web_1 | at Connection.g (events.js:291:16) web_1 | at emitTwo (events.js:106:13) web_1 | at Connection.emit (events.js:191:7) web_1 | at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:165:49) web_1 | at Socket.g (events.js:291:16) web_1 | at emitOne (events.js:96:13) web_1 | at Socket.emit (events.js:188:7) web_1 | at emitErrorNT (net.js:1281:8) web_1 | at _combinedTickCallback (internal/process/next_tick.js:74:11) web_1 | at process._tickCallback (internal/process/next_tick.js:98:9) web_1 | [nodemon] app crashed - waiting for file changes before starting... I have uploaded the image for my application at DockerHub as crissi/airlineInsurance.
In docker you can't connect to an other container via localhost because each container is independend and has its own IP. You should use container_name:port. In your example it should be db:27017 to connect from your NodeJS application in 'web' to the MongoDB in 'db'. So it's not the problem of your Dockerfile. It's the connection URL from your NodeJS application that points to localhost instead of db.