I write a docker-compose that contains a website and a mysql
in my docker-compost, ,there write as follow:
version: '2.0'
services:
website:
build:
context: /Users/Liang/Desktop/dockercompose/website/
dockerfile: ./Dockerfile
ports:
- "3001:3001"
links:
- website_mysql:website_mysql
depends_on:
- website_mysql
container_name: "website"
website_mysql:
build:
context: /Users/Liang/Desktop/dockercompose/mysql/
dockerfile: ./Dockerfile
container_name: "website_mysql"
expose:
- "3306"
environment:
- MYSQL_ROOT_PASSWORD="xA123456"
when I exec docker-compose up
there is a error when execute "npm start" in my website container. the error is a title.
maybe it caused by the remote access authority, but i don't know how to fix it
please help me, thank you very much
Is your node container configured to connect via root@website_mysql using xA123456 as the password?
It's probably also worth giving https://github.com/docker-library/postgres/issues/203#issuecomment-255200501 a read through (good info about databases, volumes, and docker-compose in general, not specific to postgres).
It works now.but i forget i how to fix it馃槀馃槀 this is my now dockerfile as follow
mysql dockerfile:
FROM mysql:5.7
MAINTAINER [email protected]
#mysql config
ARG password=xA123456
ADD ./exec.sql /exec.sql
ADD ./exec.sql /docker-entrypoint-initdb.d/exec.sql
ADD ./mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf
ENV MYSQL_ROOT_PASSWORD $password
EXPOSE 3306
cnf is
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
bind-address = 0.0.0.0
key_buffer_size = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
expire_logs_days = 10
max_binlog_size = 100M
Thank you very much! 鍗佸垎鎰熻阿馃檹
Nice! :+1: