MySQL Connection in Docker container

this is driving me crazy …

I am building a simple LEMP stack with Docker on my Mac.

  • What is the proper way of deploying versioned applications with docker?
  • Ghost Blog on Ubuntu Snappy Core OS
  • How do i wait for a db container to be up before my spring-boot app starts
  • Docker UDP port support?
  • Docker Registrator: Connection refused
  • What is causing these directories to be hidden?
  • This is my docker-compose file:

    nginx:
        image: tutum/nginx
        ports:
            - "3333:80"
        links:
            - phpfpm
            - db
        volumes:
            - ./nginx/default.conf:/etc/nginx/sites-available/default
            - ./nginx/default.conf:/etc/nginx/sites-enabled/default
    
            - ./logs/nginx-error.log:/var/log/nginx/error.log
            - ./logs/nginx-access.log:/var/log/nginx/access.log
    
    phpfpm:
        build: ./phpfpm
        ports:
            - "9000:9000"
        volumes:
            - ./code:/usr/share/nginx/html
    
    db:
      image: mysql
      tty: true
      restart: always
      volumes:
        - /Users/mauo/local/mysql/data:/var/lib/mysql
      ports:
        - "3308:3306"
      environment:
        MYSQL_DATABASE: 'docker'
        MYSQL_ROOT_PASSWORD: 'root'
        MYSQL_USER: 'root'
        MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
    

    Everything works fine, with exception on mysql container.

    This refuses me connection.

    This is the message on my php file inside code folder:

    (HY000/2002): Connection refused in /usr/share/nginx/html/index.php on line 2
    

    When I enter in mysql container with exec -it bash and I type ‘mysql’, the same thing, access denied for root@localhost.

    From within the container, I tried to launch ‘mysqld’ and it tells me

    2016-07-16T09:56:02.777893Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
        2016-07-16T09:56:02.778010Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
        2016-07-16T09:56:03.779967Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
        2016-07-16T09:56:03.780182Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    

    Any help would be appreciated!!!!

    Thank you

    M.

  • Docker does not free up space on clean operations
  • Docker-compose running container
  • How to arrange web application docker containers in production stage
  • Install Docker script error - permission denied
  • Docker on AWS filling up its thin pool while running somehow?
  • docker stop command not working correctly
  • One Solution collect form web for “MySQL Connection in Docker container”

    I’m new to docker so I could be wrong.

    Have you tried root@db.
    I think some docker magic creates DNS records for your linked containers. If you manage to get root@localhost working then please let me know. I’m having the same issue.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.