I am currently getting crazy about my docker-compose really basic configuration which does not work as it should. I am trying to make it so one service depends on the MariaDB container properly loaded, to avoid tables initialization issue. Current state is that, whatever I add as environment variables for the MariaDB container configuration, my custom healthcheck fails and even accessing the container itself, I cannot login to the mariadb server.
The docker-compose looks as follows:
version: "3.9"
services:
dbs:
build: .
ports:
- "8000:8000"
mariadb:
container_name: ${APP_NAME}_mariadb
image: mariadb
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: test
MYSQL_PASS: pass
MYSQL_DATABASE: filecoin_dbs
ports:
- 3306:3306
healthcheck:
test: mariadb --user=test --password=pass --silent --execute \"SELECT 1;\"
interval: 1s
timeout: 3s
retries: 3
volumes:
- ./mounts/mariadb:/var/lib/mysql
dbs_filecoin:
container_name: filecoin
build: ./services/dbs_filecoin/
env_file: .env
depends_on:
mariadb:
condition: service_healthy
The docker-compose up command fails on the healthcheck, with message being:
balessan#balessan-laptop:~/workspace/servers/ocean-dbs$ docker-compose up
Starting dbs_mariadb ...
ocean-dbs_dbs_1 is up-to-date
Starting dbs_mariadb ... done
ERROR: for dbs_filecoin Container "84e98cb80c06" is unhealthy.
ERROR: Encountered errors while bringing up the project.
When I access the container using a basic: docker exec -it dbs_mariadb bash command, and check mysqladmin or try to login, I get the following:
root#84e98cb80c06:/# mariadb --user=test --password=pass --silent --execute \"SELECT 1;\"
ERROR 1045 (28000): Access denied for user 'test'#'localhost' (using password: YES)
bash: ": command not found
root#84e98cb80c06:/# mysqladmin status
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
I also inspected the container status itself and it says basically the same:
...
"Health": {
"Status": "unhealthy",
"FailingStreak": 191,
"Log": [
{
"Start": "2023-01-25T16:43:39.900674472+01:00",
"End": "2023-01-25T16:43:40.019637997+01:00",
"ExitCode": 127,
"Output": "ERROR 1045 (28000): Access denied for user 'test'#'localhost' (using password: YES)\n/bin/sh: 1: \": not found\n"
},
{
"Start": "2023-01-25T16:43:41.029219694+01:00",
"End": "2023-01-25T16:43:41.144881651+01:00",
"ExitCode": 127,
"Output": "ERROR 1045 (28000): Access denied for user 'test'#'localhost' (using password: YES)\n/bin/sh: 1: \": not found\n"
},
{
"Start": "2023-01-25T16:43:42.15481382+01:00",
"End": "2023-01-25T16:43:42.2625624+01:00",
"ExitCode": 127,
"Output": "ERROR 1045 (28000): Access denied for user 'test'#'localhost' (using password: YES)\n/bin/sh: 1: \": not found\n"
},
{
"Start": "2023-01-25T16:43:43.273440938+01:00",
"End": "2023-01-25T16:43:43.407812286+01:00",
"ExitCode": 127,
"Output": "ERROR 1045 (28000): Access denied for user 'test'#'localhost' (using password: YES)\n/bin/sh: 1: \": not found\n"
},
{
"Start": "2023-01-25T16:43:44.417770011+01:00",
"End": "2023-01-25T16:43:44.563060188+01:00",
"ExitCode": 127,
"Output": "ERROR 1045 (28000): Access denied for user 'test'#'localhost' (using password: YES)\n/bin/sh: 1: \": not found\n"
}
]
}
},
...
I am starting to feel stupid so, any help really appreciated !
Related
selenium is unable to download any files from the browsers due to a 502 error on my coworkers machine, none of my other coworkers are seeing the issue, just this one dude. We are using Firefox.
After looking at the Selenoid code a bit I learned that the containers the Browser runs in uses a File Server on port 8080 to allow downloading files from the container, but I discovered that this File Server is not running within these containers.
I verified this through this command:
docker exec -it <browser_container> curl 127.0.0.1:8080
On my machine I get a 200 response:
<pre>
test.xlsx
</pre>
But when I run this command on his machine I get this error:
Failed to connect to 127.0.0.1 port 8080 after 8 ms: Connection refused
This is indicative that the File Server is not running within his Browser Containers. I've been trying many different firefox arguments and I've restart selenoid and the docker containers and still can't figure out what's going on, I'm completely lost right now. If anyone knows what might be going on I would be appreciative, or even if anyone has any idea how to gain more information into what's going on.
Here is the Firefox options we are using
options = webdriver.FirefoxOptions()
options.add_argument('--width=1600')
options.add_argument('--height=900')
options.set_preference('browser.download.dir', '/home/selenium/Downloads')
And our browsers.json file
{
"chrome": {
"default": "105.0",
"versions": {
"105.0": {
"image": "selenoid/vnc_chrome:105.0",
"port": "4444",
"path": "/",
"env": ["TZ=America/Denver"]
}
},
"caps": {
"loggingPrefs": {"browser": "ALL"},
"enableVNC": true,
"browserName": "chrome",
"timeZone": "America/Denver",
"sessionTimeout": "1m30s"
}
},
"firefox": {
"default": "latest",
"versions": {
"latest": {
"image": "selenoid/firefox",
"port": "4444",
"path": "/wd/hub",
"env": ["TZ=America/Denver"]
}
},
"caps": {
"loggingPrefs": {"browser": "ALL"},
"enableVNC": true,
"browserName": "firefox",
"timeZone": "America/Denver",
"sessionTimeout": "1m30s"
}
}
}
We do have a custom docker-compose.yml file for starting the selenoid and selenoid_ui containers, here is the file just in case that setup matters, I doubt the issue lies here.
version: "3.9"
networks:
selenoid_net:
name: selenoid_net
attachable: true
ipam:
config:
- subnet: 172.198.1.0/24
services:
selenoid:
image: aerokube/selenoid
restart: always
networks:
selenoid_net:
ports:
- "4444:4444"
environment:
- OVERRIDE_VIDEO_OUTPUT_DIR=${VIDEO_OUTPUT}/video
- TZ=America/Denver
volumes:
- "/etc/selenoid:/etc/selenoid"
- "/var/run/docker.sock:/var/run/docker.sock"
- "${VIDEO_OUTPUT}/video:${VIDEO_OUTPUT}/video"
- "${VIDEO_OUTPUT}/logs:${VIDEO_OUTPUT}/logs"
- "${PWD}:/etc/browsers"
command: ["-conf", "/etc/browsers/browsers.json",
"-video-output-dir", "${VIDEO_OUTPUT}/video",
"-log-output-dir", "${VIDEO_OUTPUT}/logs",
"-limit", "6",
"-timeout", "1m30s","-container-network", 'selenoid_net']
selenoid-ui:
image: "aerokube/selenoid-ui:latest"
restart: always
networks:
selenoid_net:
links:
- "selenoid"
ports:
- "8080:8080"
command: ["--selenoid-uri", "http://selenoid:4444"]
i have the following problem. I try to run a nakama gameserver in go with docker.
For the debugging purposes i want to use delve.
I am not really sure if i am proceeding right, so maybe my problem is actually a complete different. But i think my delve does not connect to the nakama build.
What have i done so far?
I created a new go project and put a bit code in the main.go. After that i created a Dockerfile and an docker-compose.yml.
I think in one of these two files is the mistake.
My Dockerfile looks like this:
FROM golang
ENV GOPATH /home/marc/go_projects
ENV PATH ${GOPATH}/bin:/usr/local/go/bin:$PATH
RUN go install github.com/go-delve/delve/cmd/dlv#latest
FROM heroiclabs/nakama-pluginbuilder:3.3.0 AS go-builder
ENV GO111MODULE on
ENV CGO_ENABLED 1
WORKDIR $GOPATH/gamedev
COPY go.mod .
COPY main.go .
COPY vendor/ vendor/
RUN go build --trimpath --mod=vendor --buildmode=plugin -o ./backend.so
FROM heroiclabs/nakama:3.3.0
COPY --from=go-builder /backend/backend.so /nakama/data/modules/
COPY local.yml /nakama/data/
An my docker-compose.yml
version: '3'
services:
postgres:
container_name: postgres
image: postgres:9.6-alpine
environment:
- POSTGRES_DB=nakama
- POSTGRES_PASSWORD=localdb
volumes:
- data:/var/lib/postgresql/data
expose:
- "8080"
- "5432"
ports:
- "5432:5432"
- "8080:8080"
nakama:
container_name: nakama
image: heroiclabs/nakama:3.12.0
entrypoint:
- "/bin/sh"
- "-ecx"
- >
/nakama/nakama migrate up --database.address postgres:localdb#postgres:5432/nakama &&
exec /nakama/nakama --name nakama1 --database.address postgres:localdb#postgres:5432/nakama --logger.level DEBUG --session.token_expiry_sec 7200
restart: always
links:
- "postgres:db"
depends_on:
- postgres
volumes:
- ./:/nakama/data
expose:
- "7349"
- "7350"
- "7351"
- "2345"
ports:
- "2345:2345"
- "7349:7349"
- "7350:7350"
- "7351:7351"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7350/"]
interval: 10s
timeout: 5s
retries: 5
volumes:
data:
When i build and run the docker image, it runs with no complains. I can open the webinterface of nakama, so this is running fine.
But when i try to connect the debugger, it looks like he create a succesfull connection but closes it right away.
SO my launch.json config is the following:
"name": "Connect to server",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "/home/marc/go_projects/bin/dlv",
"port": 2345,
"host": "127.0.0.1",
"trace": "verbose"
This is what i get in /tmp/vs-code-debug.txt:
[07:24:05.882 UTC] From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"go","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"de","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true})
[07:24:05.882 UTC] InitializeRequest
[07:24:05.882 UTC] To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsSetVariable":true}}
[07:24:05.883 UTC] InitializeResponse
[07:24:05.883 UTC] From client: attach({"name":"Connect to server","type":"go","request":"attach","mode":"remote","remotePath":"/home/marc/go_projects/bin/dlv","port":2345,"host":"127.0.0.1","trace":"verbose","__configurationTarget":5,"packagePathToGoModPathMap":{"/home/marc/go_projects/gamedev":"/home/marc/go_projects/gamedev"},"debugAdapter":"legacy","showRegisters":false,"showGlobalVariables":false,"substitutePath":[],"showLog":false,"logOutput":"debugger","dlvFlags":[],"hideSystemGoroutines":false,"dlvLoadConfig":{"followPointers":true,"maxVariableRecurse":1,"maxStringLen":64,"maxArrayValues":64,"maxStructFields":-1},"cwd":"/home/marc/go_projects/gamedev","dlvToolPath":"/home/marc/go_projects/bin/dlv","env":{"ELECTRON_RUN_AS_NODE":"1","GJS_DEBUG_TOPICS":"JS ERROR;JS LOG","USER":"marc","SSH_AGENT_PID":"1376","XDG_SESSION_TYPE":"x11","SHLVL":"0","HOME":"/home/marc","DESKTOP_SESSION":"ubuntu","GIO_LAUNCHED_DESKTOP_FILE":"/usr/share/applications/code.desktop","GTK_MODULES":"gail:atk-bridge","GNOME_SHELL_SESSION_MODE":"ubuntu","MANAGERPID":"1053","DBUS_SESSION_BUS_ADDRESS":"unix:path=/run/user/1000/bus","GIO_LAUNCHED_DESKTOP_FILE_PID":"6112","IM_CONFIG_PHASE":"1","MANDATORY_PATH":"/usr/share/gconf/ubuntu.mandatory.path","LOGNAME":"marc","_":"/usr/share/code/code","JOURNAL_STREAM":"8:44286","DEFAULTS_PATH":"/usr/share/gconf/ubuntu.default.path","XDG_SESSION_CLASS":"user","USERNAME":"marc","GNOME_DESKTOP_SESSION_ID":"this-is-deprecated","WINDOWPATH":"2","PATH":"/home/marc/.nvm/versions/node/v17.8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/go/bin","SESSION_MANAGER":"local/mobile:#/tmp/.ICE-unix/1458,unix/mobile:/tmp/.ICE-unix/1458","INVOCATION_ID":"fe605ca56aa646859602b81e264bf01b","XDG_RUNTIME_DIR":"/run/user/1000","XDG_MENU_PREFIX":"gnome-","DISPLAY":":0","LANG":"de_DE.UTF-8","XDG_CURRENT_DESKTOP":"Unity","XAUTHORITY":"/run/user/1000/gdm/Xauthority","XDG_SESSION_DESKTOP":"ubuntu","XMODIFIERS":"#im=ibus","SSH_AUTH_SOCK":"/run/user/1000/keyring/ssh","SHELL":"/bin/bash","QT_ACCESSIBILITY":"1","GDMSESSION":"ubuntu","GPG_AGENT_INFO":"/run/user/1000/gnupg/S.gpg-agent:0:1","GJS_DEBUG_OUTPUT":"stderr","QT_IM_MODULE":"ibus","PWD":"/home/marc","XDG_DATA_DIRS":"/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop","XDG_CONFIG_DIRS":"/etc/xdg/xdg-ubuntu:/etc/xdg","_WSREP_START_POSITION":"","CHROME_DESKTOP":"code-url-handler.desktop","ORIGINAL_XDG_CURRENT_DESKTOP":"ubuntu:GNOME","VSCODE_CWD":"/home/marc","GDK_BACKEND":"x11","VSCODE_NLS_CONFIG":"{\"locale\":\"de\",\"availableLanguages\":{\"*\":\"de\"},\"_languagePackId\":\"b61d3f473b0358bc955527db7340fd23.de\",\"_translationsConfigFile\":\"/home/marc/.config/Code/clp/b61d3f473b0358bc955527db7340fd23.de/tcf.json\",\"_cacheRoot\":\"/home/marc/.config/Code/clp/b61d3f473b0358bc955527db7340fd23.de\",\"_resolvedLanguagePackCoreLocation\":\"/home/marc/.config/Code/clp/b61d3f473b0358bc955527db7340fd23.de/30d9c6cd9483b2cc586687151bcbcd635f373630\",\"_corruptedFile\":\"/home/marc/.config/Code/clp/b61d3f473b0358bc955527db7340fd23.de/corrupted.info\",\"_languagePackSupport\":true}","VSCODE_CODE_CACHE_PATH":"/home/marc/.config/Code/CachedData/30d9c6cd9483b2cc586687151bcbcd635f373630","VSCODE_IPC_HOOK":"/run/user/1000/vscode-432c1660-1.68.1-main.sock","VSCODE_PID":"6112","NVM_INC":"/home/marc/.nvm/versions/node/v17.8.0/include/node","LS_COLORS":"","NVM_DIR":"/home/marc/.nvm","LESSCLOSE":"/usr/bin/lesspipe %s %s","LESSOPEN":"| /usr/bin/lesspipe %s","NVM_CD_FLAGS":"","NVM_BIN":"/home/marc/.nvm/versions/node/v17.8.0/bin","GOPATH":"/home/marc/go_projects","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_PIPE_LOGGING":"true","VSCODE_VERBOSE_LOGGING":"true","VSCODE_LOG_NATIVE":"false","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_LOG_STACK":"false","VSCODE_IPC_HOOK_EXTHOST":"/run/user/1000/vscode-ipc-8cf508cc-d427-4616-b6b5-61d3c3e5d99f.sock","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","GOMODCACHE":"/home/marc/go_projects/pkg/mod","GOPROXY":"https://proxy.golang.org,direct"},"__sessionId":"1893ab9e-5a19-45e7-8b39-46db079cdbe3"})
[07:24:05.883 UTC] AttachRequest
[07:24:05.884 UTC] Start remote debugging: connecting 127.0.0.1:2345
[07:24:06.191 UTC] To client: {"seq":0,"type":"event","event":"initialized"}
[07:24:06.192 UTC] InitializeEvent
[07:24:06.192 UTC] To client: {"seq":0,"type":"response","request_seq":2,"command":"attach","success":true}
[07:24:06.194 UTC] [Error] Socket connection to remote was closed
[07:24:06.194 UTC] Sending TerminatedEvent as delve is closed
[07:24:06.194 UTC] To client: {"seq":0,"type":"event","event":"terminated"}
[07:24:06.201 UTC] From client: configurationDone(undefined)
[07:24:06.201 UTC] ConfigurationDoneRequest
[07:24:06.225 UTC] From client: disconnect({"restart":false})
[07:24:06.225 UTC] DisconnectRequest
I tried to change the remote path i the launch.json multiple times, try to math the paths in the docker files.
Maybe i have to change the implementation of delve in docker, but tbh i dont really know how. I dont really find a good documentation on how to do this.
I was having the same problem.
I solved it like this:
adding line: "debugAdapter": "dlv-dap" on my launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Delve into Docker",
"type": "go",
"request": "attach",
"debugAdapter": "dlv-dap",
"mode": "remote",
"substitutePath": [
{
"from": "${workspaceFolder}/",
"to": "/app",
},
],
"port": 2345,
"host": "127.0.0.1",
"showLog": false,
"apiVersion": 2,
"trace": "verbose"
}
]
}
I want to start postgres container with init script.
request := testcontainers.ContainerRequest{
Image: "postgres:14.1-alpine",
Entrypoint: nil,
Env: map[string]string{
"POSTGRES_DB": "postgres",
"PGUSER": "postgres",
"POSTGRES_PASSWORD": "postgres",
//"PGDATA": "postgres",
},
ExposedPorts: []string{"5432"},
BindMounts: map[string]string{
"/media/mihovelgod/Новый том1/GoProjects/microservices/sql/go-sql/resources/migrations": "/docker-entrypoint-initdb.d",
},
Name: "postgres",
User: "postgres",
WaitingFor: wait.ForLog("database system is ready to accept connections"),
AutoRemove: true,
}
container, err = testcontainers.GenericContainer(
test.CTX,
testcontainers.GenericContainerRequest{
ContainerRequest: request,
Started: true,
},
)
if err != nil {
log.Panicln(err)
}
I got the following panic messages in log.Panicln(err):
failed to create container
Error response from daemon
invalid mount config for type "bind": bind source path does not exist: /docker-entrypoint-initdb.d
The point is that it perfectly works from docker-compose.yml.
How to fix this?
Looking at the source, it appears that TestContainers wants container_path: host_path in BindMounts. What happens if you try:
BindMounts: map[string]string{
"/docker-entrypoint-initdb.d": "/media/mihovelgod/Новый том1/GoProjects/microservices/sql/go-sql/resources/migrations",
},
It looks like more recent versions of TestContainers have removed BindMounts completely and replaced it with a more generic Mounts field.
Team
I have a docker compose file which throws below erros
fatal: [10.0.1.4]: FAILED! => {"changed": true, "cmd": "bash setup.sh\n", "delta": "0:00:00.629193", "end": "2021-08-18 20:53:27.578148", "msg": "non-zero return code", "rc": 1, "start": "2021-08-18 20:53:26.948955", "stderr": "yaml.parser.ParserError: while parsing a block collection\n in \"./docker-compose.yaml\", line 14, column 7\nexpected <block end>, but found '<scalar>'\n in \"./docker-compose.yaml\", line 15, column 68", "stderr_lines": ["yaml.parser.ParserError: while parsing a block collection", " in \"./docker-compose.yaml\", line 14, column 7", "expected <block end>, but found '<scalar>'", " in \"./docker-compose.yaml\", line 15, column 68"], "stdout": "", "stdout_lines": []}
Not sure where it's going wrong and below is my Docker-Compose file
version: '3.7'
networks:
default:
external:
name: vr0
services:
demoproject:
build:
dockerfile: Dockerfile
context: .
ports:
- '8080:8080'
volumes:
- /usr/share/logData:/log
- {{ wms_input_path | default('/opt/vr/demoproject/wms/input') }}:/wms/input
- {{ wms_output_path | default('/opt/vr/demoproject/wms/output') }}:/wms/output
restart: always
labels:
filebeat_enable:
env_file:
- ./.env
I have 2 different containers running with docker-compose. Here is my docker-compose.yml:
version: '3'
services:
#Create backend container
backend:
build: ./backend # path to Dockerfile
ports: # Port binding to host from docker container
- "5000:5000"
container_name: buzzworks-backend
volumes:
- ${PWD}/backend:/app
depends_on:
- db
environment:
FLASK_APP: flaskr
FLASK_ENV: development
NEO_USER: ${NEO_USER}
NEO_PW: ${NEO_PW}
db:
image: neo4j:4.1.1
container_name: buzzworks-neo4j
ports:
- "7474:7474"
- "7687:7687"
volumes:
- ${HOME}/neo4j/data:/data
- ${HOME}/neo4j/logs:/logs
- ${HOME}/neo4j/import:/var/lib/neo4j/import
- ${HOME}/neo4j/plugins:/plugins
environment:
NEO4J_AUTH: ${NEO_USER}/${NEO_PW}
NEO4J_dbms_logs_debug_level: ${NEO_DEBUG_LEVEL}
The corresponding network it generates looks right to me:
{
"Name": "buzzworksai_default",
"Id": "db4efc0286a9464cadde13cf1306f241b7a353295904b15b163e761289ba9d3f",
"Created": "2020-08-27T11:23:15.925483629-04:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"640650c163f746e480bf677abdeaf8edf6483b7dac2a260c2e3b3bc3319dffef": {
"Name": "buzzworks-neo4j",
"EndpointID": "ddbad1a179cc51655a779b07c91d6d949b0612bf985abc9c45e1794b35f4a565",
"MacAddress": "02:42:ac:12:00:03",
"IPv4Address": "172.18.0.3/16",
"IPv6Address": ""
},
"ba47173d1dbc31e4e416eaf30d2314e6d2a20a36b389cb76cd1edcbea489184e": {
"Name": "buzzworks-backend",
"EndpointID": "17ff278f3db5ad609be682cdf912ca755587e07ef08d6023bf3ecb33a6c4bc31",
"MacAddress": "02:42:ac:12:00:02",
"IPv4Address": "172.18.0.2/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "default",
"com.docker.compose.project": "buzzworksai",
"com.docker.compose.version": "1.26.2"
}
}
]
I can access the web interface of the neo4j database just fine. The problem occurs when I am trying to connect to the database with neomodel. I have tried running neomodel_remove_labels --db bolt://<user>:<password>#db:7687 with the appropriate credentials from the shell of the python container. I get this error:
Traceback (most recent call last):
File "/usr/local/bin/neomodel_remove_labels", line 35, in <module>
main()
File "/usr/local/bin/neomodel_remove_labels", line 30, in main
db.set_connection(bolt_url)
File "/usr/local/lib/python3.8/dist-packages/neomodel/util.py", line 93, in set_connection
self.driver = GraphDatabase.driver(u.scheme + '://' + hostname,
File "/usr/local/lib/python3.8/dist-packages/neo4j/__init__.py", line 108, in driver
return Driver(uri, **config)
File "/usr/local/lib/python3.8/dist-packages/neo4j/__init__.py", line 147, in __new__
return subclass(uri, **config)
File "/usr/local/lib/python3.8/dist-packages/neo4j/__init__.py", line 221, in __new__
pool.release(pool.acquire())
File "/usr/local/lib/python3.8/dist-packages/neobolt/direct.py", line 715, in acquire
return self.acquire_direct(self.address)
File "/usr/local/lib/python3.8/dist-packages/neobolt/direct.py", line 608, in acquire_direct
connection = self.connector(address, error_handler=self.connection_error_handler)
File "/usr/local/lib/python3.8/dist-packages/neo4j/__init__.py", line 218, in connector
return connect(address, **dict(config, **kwargs))
File "/usr/local/lib/python3.8/dist-packages/neobolt/direct.py", line 972, in connect
raise last_error
File "/usr/local/lib/python3.8/dist-packages/neobolt/direct.py", line 963, in connect
s, der_encoded_server_certificate = _secure(s, host, security_plan.ssl_context, **config)
File "/usr/local/lib/python3.8/dist-packages/neobolt/direct.py", line 854, in _secure
s = ssl_context.wrap_socket(s, server_hostname=host if HAS_SNI and host else None)
File "/usr/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/usr/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/usr/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
OSError: [Errno 0] Error
I have tried to access the container from my host with bolt://<user>:<password>#localhost:7687 but I still get the same error.
I believe this may be your issue which is related to neo4j: https://github.com/neo4j/neo4j/issues/12392
The suggestion there is:
Neo4j 4.0 has encryption turned off by default. You need to explicitly
turn encryption back on for Bolt server in server config file. Then
you shall be able to connect using 1.7 python driver with default
settings.
The following is an example of how you can turn encryption back on
Bolt Server with private.key and public.crt in directory
$neo4jHome/certificates/bolt.
dbms.connector.bolt.enabled=true
# allows both encrypted and unencrypted driver connections
dbms.connector.bolt.tls_level=OPTIONAL
dbms.ssl.policy.bolt.enabled=true
dbms.ssl.policy.bolt.base_directory=certificates/bolt
#dbms.ssl.policy.bolt.private_key=private.key
#dbms.ssl.policy.bolt.public_certificate=public.crt
You can choose any trusted key and certificate service to generate the
private key and public certificate used here.
You need to set the network option on your docker-compose file. Please read this link and then you will understand it well.
You should do something like this:
version: '3'
services:
#Create backend container
backend:
build: ./backend # path to Dockerfile
ports: # Port binding to host from docker container
- "5000:5000"
container_name: buzzworks-backend
volumes:
- ${PWD}/backend:/app
depends_on:
- db
environment:
FLASK_APP: flaskr
FLASK_ENV: development
NEO_USER: ${NEO_USER}
NEO_PW: ${NEO_PW}
networks:
- mynetwork
db:
image: neo4j:4.1.1
container_name: buzzworks-neo4j
ports:
- "7474:7474"
- "7687:7687"
volumes:
- ${HOME}/neo4j/data:/data
- ${HOME}/neo4j/logs:/logs
- ${HOME}/neo4j/import:/var/lib/neo4j/import
- ${HOME}/neo4j/plugins:/plugins
environment:
NEO4J_AUTH: ${NEO_USER}/${NEO_PW}
NEO4J_dbms_logs_debug_level: ${NEO_DEBUG_LEVEL}
networks:
- mynetwork
networks:
mynetwork: