Basically I'm trying to setup a environment with elasticsearch and kibana with docker on a m1 mac. I've setup the de env variable DOCKER_DEFAULT_PLATFORMto linux/amd64. Everything seems fine on running the container but when I try to connect kibana to elastic they just can't see each other. This is my current docker-composer file:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.3.3-amd64
environment:
- discovery.type=single-node
- node.name=elasticsearch1
- cluster.name=docker-cluster
- cluster.initial_master_nodes=elasticsearch1
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms128M -Xmx128M"
ports:
- 9200:9200
networks:
- my-network
kibana:
image: docker.elastic.co/kibana/kibana:8.3.3-amd64
environment:
SERVER_NAME: localhost
ELASTICSEARCH_URL: http://localhost:9200/
ports:
- 5601:5601
depends_on:
- elasticsearch
networks:
- my-network
Before that I was using links insted of networks, no luck with that either. From my terminal or browser I can see both elastic and kibana running on their respective ports. I'm without ideas here, appreciate any help!
EDIT
docker ps output
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
265023669cfd docker.elastic.co/kibana/kibana:8.3.3-amd64 "/bin/tini -- /usr/l…" 14 minutes ago Up 14 minutes 0.0.0.0:5601->5601/tcp folha3_kibana_1
48ee37663dda docker.elastic.co/elasticsearch/elasticsearch:8.3.3-amd64 "/bin/tini -- /usr/l…" 14 minutes ago Up 14 minutes 0.0.0.0:9200->9200/tcp, 9300/tcp folha3_elasticsearch_1
6b1f6dd9473f redis "docker-entrypoint.s…" 14 minutes ago Up 14 minutes 0.0.0.0:6379->6379/tcp folha3_redis_1
2a3ade65634a mysql:5.7 "docker-entrypoint.s…" 14 minutes ago Up 14 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp folha3_mysql_1
ELASTICSEARCH_URL: http://localhost:9200/ should be http://my-network:9200/, localhost can't access elasticsearch container.
Related
I'm using docker with docker-compose.yml file.
There I put two different services inside, which I'd like to update.
Moreover I ran portainer and added also some other services there:
pi#raspberrypi:~/docker $ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ec830e789d38 nodered/node-red:latest "npm --no-update-not…" 8 days ago Up 6 minutes (healthy) 0.0.0.0:1880->1880/tcp, :::1880->1880/tcp docker_node-red_1
15aa942b2b94 openhab/openhab:3.1.1 "/entrypoint gosu op…" 8 days ago Up 8 days (healthy) docker_openhab_1
e805e3f527c4 portainer/portainer-ce "/portainer" 8 days ago Up 8 days 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp, 0.0.0.0:9443->9443/tcp, :::9443->9443/tcp portainer
80990d1ad7e7 influxdb:latest "/entrypoint.sh infl…" 9 months ago Up 8 days InfluxDB
My actual docker-compose.yml file looks like this:
pi#raspberrypi:~/docker $ cat docker-compose.yml
version: "2"
services:
openhab:
image: "openhab/openhab:3.1.1"
restart: always
network_mode: host
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "/etc/timezone:/etc/timezone:ro"
- "./openhab_addons:/openhab/addons"
- "./openhab_conf:/openhab/conf"
- "./openhab_userdata:/openhab/userdata"
environment:
USER_ID: "1000"
GROUP_ID: "1000"
OPENHAB_HTTP_PORT: "8080"
OPENHAB_HTTPS_PORT: "8443"
EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin"
services:
node-red:
image: nodered/node-red:latest
environment:
- TZ=Europe/Amsterdam
ports:
- "1880:1880"
networks:
- node-red-net
volumes:
- node-red-data:/data
devices:
- "/dev/ttyUSB0:/dev/ttyUSB0"
volumes:
node-red-data:
networks:
node-red-net:
In order to update the openhab container from 3.1.1 to 3.2.0, I changed the image name inside compose file to openhab/openhab:3.2.0.
Afterwards I started docker-compose pull and the system only checked if there is a new image for node-red available. But not for openhab.
What is wrong?
You need to put all the services under a single services key. That's also why it's plural.
services:
openhab:
...
node-red:
...
I installed Kafka on a VM Ubuntu 18.0.4 with following compose file
version: '2'
networks:
kafka-net:
driver: bridge
services:
zookeeper-server:
image: 'bitnami/zookeeper:latest'
networks:
- kafka-net
ports:
- '2181:2181'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
kafka-server1:
image: 'bitnami/kafka:latest'
networks:
- kafka-net
ports:
- '9092:9092'
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper-server:2181
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://:9092
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper-server
kafka-server2:
image: 'bitnami/kafka:latest'
networks:
- kafka-net
ports:
- '9093:9092'
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper-server:2181
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://:9093
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper-server
It installed without any problem.
sudo docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
39f38caf57cb bitnami/kafka:latest "/entrypoint.sh /run…" 3 hours ago Up 5 minutes 0.0.0.0:9092->9092/tcp kafka_kafka-server1_1
088a703b5b76 bitnami/kafka:latest "/entrypoint.sh /run…" 3 hours ago Up 3 hours 0.0.0.0:9093->9092/tcp kafka_kafka-server2_1
6a754bda47ea bitnami/zookeeper:latest "/entrypoint.sh /run…" 3 hours ago Up 3 hours 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, 8080/tcp kafka_zookeeper-server_1
Now, I want to connect to my Kafka on my VM with the following setting:
I test it from localhost with the following
root#ubuntu:~# kafkacat -b 192.168.179.133:9092 -L
Metadata for all topics (from broker -1: 192.168.179.133:9092/bootstrap):
1 brokers:
broker 1001 at localhost:9092
0 topics:
But in my windows 10 I can not connect to 192.168.179.133:9092 with Conduktor
As you see it returns error.
Test ZK is OK but Test kafka Connectivity raise the error !
You should change KAFKA_CFG_ADVERTISED_LISTENERS if your conductor is not installed in the same machine as Kafka cluster installed.
It should be like this for kafka-server1:
KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.179.33:9092
and kafka-server2:
KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.179.33:9093
Note: You should consider to add both kafka servers in conductor for redundancy.
You can check this for more information.
I am having an application service and a MySQL service but I am not able to connect the two containers and it keeps returning me this error
jango.db.utils.OperationalError: (2002, "Can't connect to MySQL server on '127.0.0.1' (115)")
I have included the links in my application service but nothing is working out.
Mine MySQL container is working up fine and even I can log into the MySQL container.
Here is the snapshot of the services:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cc26d09a81d1 gmasmatrix_worker:latest "/entrypoint.sh /sta…" 17 seconds ago Exited (1) 11 seconds ago gmasmatrix_celeryworker_1
749f23c37b16 gmasmatrix_application:latest "/entrypoint.sh /sta…" 18 seconds ago Exited (1) 9 seconds ago gmasmatrix_application_1
666029ad063a gmasmatrix_flower "/entrypoint.sh /sta…" 18 seconds ago Exited (1) 10 seconds ago gmasmatrix_flower_1
50ac0497e66b mysql:5.7.10 "/entrypoint.sh mysq…" 21 seconds ago Up 17 seconds 0.0.0.0:3306->3306/tcp gmasmatrix_db_1
669fbbe0a81d mailhog/mailhog:v1.0.0 "MailHog" 21 seconds ago Up 18 seconds 1025/tcp, 0.0.0.0:8025->8025/tcp gmasmatrix_mailhog_1
235a46c8d453 redis:5.0 "docker-entrypoint.s…" 21 seconds ago Up 17 seconds 6379/tcp gmasmatrix_redis_1
Docker-compose file
version: '2'
services:
application: &application
image: gmasmatrix_application:latest
command: /start.sh
volumes:
- .:/app
# env_file:
# - .env
ports:
- 8000:8000
# cpu_shares: 874
# mem_limit: 1610612736
# mem_reservation: 1610612736
build:
context: ./
dockerfile: ./compose/local/application/Dockerfile
args:
- GMAS_ENV_TYPE=local
links:
- "db"
celeryworker:
<<: *application
image: gmasmatrix_worker:latest
depends_on:
- redis
- mailhog
ports: []
command: /start-celeryworker
links:
- "db"
flower:
<<: *application
image: gmasmatrix_flower
ports:
- "5555:5555"
command: /start-flower
links:
- "db"
mailhog:
image: mailhog/mailhog:v1.0.0
ports:
- "8025:8025"
redis:
image: redis:5.0
db:
image: mysql:5.7.10
environment:
MYSQL_DATABASE: gmas_mkt
MYSQL_ROOT_PASSWORD: pulkit1607
ports:
- "3306:3306"
``
Your application is trying to connect to 127.0.0.1 - which in docker points to the app container itself.
Instead you should use the IP of the db container. You can utilize the built-in docker DNS service to do this. In your application configuration, use db (the name of the mysql container) as the host to connect to instead of localhost or 127.0.0.1
I have a bunch of containers running on my ubuntu laptop.As you can see below, I should be able to type in localhost:8080 in the browser and get some response. Instead I get
ERR_CONNECTION_REFUSED
Any idea why?
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
143fbe3867e3 richb201/apache-with-code:latest "/app-entrypoint.sh …" 19 hours ago Up 19 hours 8080/tcp, 0.0.0.0:8000->8000/tcp, 8443/tcp sub_crud_webserver_1
0c2048ef273e bitnami/mariadb:latest "/entrypoint.sh /run…" 21 hours ago Up 21 hours 3306/tcp sub_crud_mariadb_1
fb30f99f037b bitnami/php-fpm:latest "php-fpm -F --pid /o…" 2 days ago Up 19 hours 9000/tcp html_php-fpm_1
be5155202f43 bitnami/mariadb:latest "/entrypoint.sh /run…" 2 days ago Up 19 hours 3306/tcp html_mariadb_1
docker-compose.yml
version: '3'
services:
webserver:
image: richb201/apache-with-code:latest
ports:
- '8000:8000'
volumes:
- /sub_crud:/var/www/html/sub_crud
environment:
XDEBUG_CONFIG: remote_host='richb201-XPS-13-9370'
mariadb:
image: bitnami/mariadb:latest
environment:
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- mariadb-data:/bitnami
php-fpm:
image: bitnami/php-fpm:latest
volumes:
- /sub_crud:/var/www/html/sub_crud
volumes:
According to your docker-compose that you mentioned in a comment (better put this into your question though) you map port 8000 to port 8000. Hence, any requests going to port 8000 on your local machine are received from port 8000 within your container.
If you want to use port 8080 you have to adapt the docker-compose file accordingly, i.e., 8080:8080. Note here that I assume that the apache server in your richb201/apache-with-code image is running on port 8080.
when i run docker ps i am seeing port 80 unmapped on the apphub-ui container, i am expecting it to be mapped to 4200, which i also see. I dont understand why 80/tcp is present, it is creating connection refused issues in my app.
Here is the docker ps output
docker ps 10s +59%
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
22cb2b9c28d4 swimlane/apphub-ui:latest "/usr/bin/reefer -t …" 20 seconds ago Up 17 seconds 80/tcp, 0.0.0.0:80->4200/tcp apphub_apphub-ui_1
19a78f93bfe7 swimlane/apphub-api:latest "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 0.0.0.0:3000->3000/tcp apphub_apphub-api_1
7b3478e2dcd5 mongo:3.6 "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 0.0.0.0:27017->27017/tcp apphub_mongo_1
My docker-compose file is as follows
version: '3.6'
volumes:
mongo:
services:
mongo:
image: mongo:3.6
ports:
- 27017:27017
volumes:
- mongo:/data/db
apphub-api:
image: swimlane/apphub-api:latest
ports:
- 3000:3000
depends_on:
- mongo
apphub-ui:
image: swimlane/apphub-ui:latest
ports:
- 80:4200
depends_on:
- apphub-api
environment:
- APPHUB_API_HOST=apphub-api
My app runs fine if i change the mapped ports for the ui feature to 4200:4200, and i dont see the stray unmapped 80
I'm having the feeling that you want to map the port 4200 on your host to the port 80 of your container. If that's the case, you should switch the values. i.e.
ports:
- 4200:80