I am have installed Couchbase on Docker using docker-compose file.
version: '2'
services:
couchbase-server:
container_name: project-couchbase
image: couchbase/server
ports:
- 4369:4369
- 8091:8091
- 8092:8092
- 8093:8093
- 8094:8094
- 11210:11210
- 11211:11211
volumes:
- $HOME/couchbasesql:/var/lib/couchbase/data
Installation went fine but while creating cluster when i give my machine ip, I am getting following error
I have used all solution on google but still i am stuck here, it is taking 127.0.0.1 but not my machine ip which is needed for Couchbase clustering.
Can somebody help me on this ?
Related
this is my first question on Stackoverflow, I was forced because despite finding different solutions to my problem none of them worked for me.
I am trying to study the docker composting system and have created a configuration file that includes four elements: web, API, DB, and phpMyAdmin.
Initially, it was composed of only three elements web, DB, and phpMyAdmin, once I was sure that everything worked properly I moved on to the next step, that of adding the API.
Unfortunately, there was no way to connect the API to the DB, although phpMyAdmin is able to connect to the DB without any problem.
Obviously, the same API launched in debug and configured to connect to the local MySQL server works without any problem.
This is the yml file that I'm trying to get to work:
version: '3.3'
services:
web:
env_file:
- DockerImg/email.env
build:
context: .
dockerfile: DockerImg/web.Dockerfile
container_name: armedia-web
ports:
- 8080:80
volumes:
- "./DockerImg/web:/var/www/html"
- "./DockerImg/php/php.ini:/usr/local/etc/php/php.ini"
links:
- db
depends_on:
- db
api:
build:
context: .
dockerfile: Dockerfile
container_name: armedia-api
ports:
- 8082:80
links:
- db
depends_on:
- db
env_file:
- DockerImg/dbarmedia.env
environment:
- DBHOST=db
db:
build:
context: .
dockerfile: DockerImg/db.Dockerfile
container_name: armedia-db
volumes:
- "./DockerImg/db:/var/lib/mysql"
environment:
- MYSQL_USER=root
- MYSQL_ROOT_PASSWORD=******
- MYSQL_DATABASE=armedia
phpmyadmin:
image: phpmyadmin/phpmyadmin:4.8.3
container_name: armedia-phpmyadmin
ports:
- 8081:80
links:
- db
depends_on:
- db
environment:
- PMA_HOST=db
- PMA_USER=root
- PMA_PASSWORD=******
dbarmedia.env contains:
DBUSER=root
DBPASS=******
DBNAME=armedia
First of all, whatever I write on env_file or environment of the API section does not affect the connectionstring that is actually used by the API.
In fact, when it goes in error, it writes the connectionstring and this is exactly what I put in the appsettings.json of the API project:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"Default": "Server=db;Port=3306;Uid=root;Pwd=******;Database=armedia;"
}
}
The error it returns to me is "Error: Couldn't connect to server"
I tried to replace DB with 127.0.0.1 or localhost, also put db:3306 and 127.0.0.1:3306 as found on some suggestions but it doesn't work, at most the error varies from "Error: Couldn't connect to server" to "Error: Unable to connect to any of the specified MySQL hosts."
I would be very happy if someone could give me some suggestions on how to solve it because I have been looking for a solution without success for days and I think this configuration I am trying is quite "particular"
Many thanks in advance.
I managed to solve the problem and I am exposing the solution because it might be useful to someone.
Actually the problem was related to the MySQL version.
Apparently Net 6 must have some incompatibility problems with the version I was using on the Docker Container:
FROM mysql: 5.7.21
Only time later did I ask myself the question, which version am I using on the PC where the connection works?
mysql Ver 8.0.31-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
I then changed the Dockefile of the db to:
FROM mysql:8.0.31
And as if by magic it started working properly.
I hope you find it useful, good evening.
this is my docker-compose-yml file. first i tried to run the db service it work fined and docker running successfully. but when I run the app service, in the terminal it says connected to database but I get an error as (2003, "Can't connect to MySQL server on '127.0.0.1')
version: '4'
services:
app:
build: .
ports:
- "8000:8000"
env_file:
- .env
depends_on:
- db
links:
- db
db:
environment:
- MYSQL_ROOT_PASSWORD=root
-
image: mysql
ports:
- "3307:3307"
env_file:
- .env
enter image description here
What environment variable is the FastAPI app using to connect to the MySQL host?
If you're using docker-compose networking, services need to use the container name in order to reach each other (i.e. mysql://db:3307/db_name_here) not localhost.
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.
More information on networking can be found in their docs here.
Also worth noting, since you're using links you can set aliases as well like so:
version: "3.9"
services:
web:
build: .
links:
- "db:database"
db:
image: postgres
Links Docs Source
I have setup docker environment in my local machine to run our development code by pointing to dev mysql database url. Done all configurations and was able to build the docker using docker-compose build command. Even though i was able to build it successfully , on running the command docker-compose up , i am getting numerous errors.
Few of the errors are :
ERROR - TransactionManager Failed to start new registry transaction.
ERROR- AsyncIndexer. Error while indexing
I saw another answers in stackoverflow and updated my code accordingly like limiting max active connections to field to 50 in master-datasources.xml file and changing the configuration url to the below format.
jdbc:mysql://${db_url}:${db_port}/${carbon_db}?autoReconnect=true&relaxAutoCommit=true
Docker version : 19.03.5
Docker compose version : 1.24.1
My docker-compose.yml file:
services:
wso2am:
build: ./apim
image: wso2am:2.1.0
env_file:
- sample.env
ports:
- "9444:9444"
- "8281:8281"
- "8244:8244"
depends_on:
- wso2is-km
wso2is-km:
build: ./is-as-km
image: wso2is-km:5.3.0
env_file:
- sample.env
ports:
- "9443:9443"
My sample.env file:
HOST_NAME=<hostname>
DB_URL=<db_connection_url>
DB_USER=admin
DB_PASS=adminpassword
DB_PORT=3306
CARBON_DB=carbondb
APIM_DB=apimdb
ADMIN_PASS=<wso2_password>
Can anyone provide a solution for this issue.
I'm running MySQL inside the latest official MySQL docker container.
The host machine is Windows 10.
I'm using "docker-compose up mysql" to start the following service:
version: '3.4'
services:
mysql:
image: mysql/mysql-server:latest
container_name: sqlstore
ports:
- '3306:3306'
expose:
- '3306'
env_file:
- ./sqlconfig.env
volumes:
- ./data:/var/lib/mysql
The problem that I'm having is when MySQL database files reside on the host's volume, MySQL fails to run and I keep getting the following error message:
"do you already have another mysqld server running on the socket: "/var/lib/mysql/mysql.sock""
It is worth noting that I did make sure that the port is not being used by other processes, and MySQL's files are indeed being written to the ./data directory on the host.
However, when the MySQL files do not reside on the host but inside the docker itself, everything runs correctly.
I had the same problem. If you're on Linux container, the issue is very likely related to different file-system type that the MySQL container has and the Windows host machine. Using named volumes i.e. some-data:/var/lib/mysql might resolve the issue. Working example:
version: '3.4'
services:
mysql:
image: mysql/mysql-server:latest
container_name: sqlstore
ports:
- '3306:3306'
expose:
- '3306'
env_file:
- ./sqlconfig.env
volumes:
- datavol:/var/lib/mysql
volumes:
datavol:
Docker noob alert. Hope this isn't a dumb question but I cannot seem to figure out what is going on. I am trying to create a docker-compose file which creates a mysql db with a mounted volume and a go webserver app that connects to the mysql db.
Here is my docker-compose file:
services:
db:
image: mysql:8.0.2
environment:
MYSQL_ROOT_PASSWORD: test
MYSQL_DATABASE: northernairport
ports:
- "3306:3306"
volumes:
- /data:/var/lib/mysql
web:
depends_on:
- db
build: .
ports:
- "8080:8080"
My go application can't seem to connect to my mysql db though, I thought the "depends_on" would ensure this was possible.
Error I get:
panic: dial tcp 127.0.0.1:3306: getsockopt: connection refused
Can anyone tell me what I am doing wrong here? Thanks.
The depends_on only controls the build and startup order for the services.
Your actual issue is more likely that you are using the wrong address from your web application to your database. I see that you have not defined any networks, so you are using the default network created for your application by docker-compose. This will publish each service by name on the default network's DNS.
So, your web application should probably be using db:3306 as the database address, not localhost:3306 or 127.0.0.1:3306 as indicated in the error message.
The ports part is used to map container ports with host in following format ports (HOST:CONTAINER). Which means that you are trying to access host's machine, configure web app to connect to db:3306 instead.