the following file is a docker-compose file. If I execute it via docker-compose up the container create itselfs but is impossible to connect to server, via terminal as via database visual editor. And, if I check the container via docker inspect by terminal, some vaule (i.e. IPaddress) are empty.
If I try to create the same container but manually via docker run command, passing the same parameters via command line, all works perfectly and if I check the container via docker inspect via terminal, all values are correct (also, in particular, IP address) and I can connect to the database so via terminal as via db visual editor.
Why it happens, and why in particular creating the mySql container via this docker-compose file the ipaddress seems empty? Is my docker compose file not correct? I checked several times with
version: '3.6' services: mysql: image: mysql:5.7 restart: unless-stopped environment: - MYSQL_ROOT_PASSWORD=xyz ports: - 127.0.0.1:port_number:port_number volumes: - mysql:/var/lib/mysql - ./mysql-init:/docker-entrypoint-initdb.d command: - --max-allowed-packet=64M volumes: mysql: {} EDIT: to reply to 2 users,
1) Port_number was exactly 3306 in the orginal file; 2) The full run command is
sudo docker run --name my_mysql -e MYSQL_ROOT_PASSWORD=my_password -p 3306:3306 mysql:5.7
docker runcommand you use.ports: 3306:3306docker inspectoutput is pretty low-level debugging information that isn't usually useful, and in particular the IP address it reports doesn't work in many extremely common contexts.