Custom Docker MySQL build won't run

I am trying to compose my custom Dockerfile for setting up Mysql 5.7.

As part of this I would like to set s3 backup as well.

  • create a web2py docker image and access it through browser
  • Big size of python image in Docker
  • Is it possible to run match servers on Kubernetes for a Real Time Multiplayer game?
  • How to derive port mappings inside a docker container?
  • docker unit test setup
  • How to change ip address of docker0 bridge interface on Docker Toolbox
  • But when I try to run/create the docker instance it fails

    Here is the Dockerfile:

    # Start with a base mysql:5.6 image
    FROM mysql:5.7
    
    MAINTAINER Ikenna N. Okpala <me@ikennaokpala.com>
    
    USER root
    # RUN locale-gen
    ENV DEBIAN_FRONTEND noninteractive
    ENV LANG en_US.UTF-8
    ENV LANGUAGE en_US.en
    ENV LC_ALL en_US.UTF-8
    ENV PS_NGX_EXTRA_FLAGS --with-cc=/usr/bin/gcc --with-ld-opt=-static-libstdc++
    
    
    # Add all base dependencies
    RUN apt-get update -y
    
    RUN apt-get install -y build-essential checkinstall
    RUN apt-get install -y vim curl wget unzip
    RUN apt-get install -y libfuse-dev libcurl4-openssl-dev mime-support automake libtool python-docutils libreadline-dev
    RUN apt-get install -y pkg-config libssl-dev
    RUN apt-get install -y git-core
    RUN apt-get install -y man cron
    RUN apt-get install -y libgmp-dev
    RUN apt-get install -y zlib1g-dev
    RUN apt-get install -y libxslt-dev
    RUN apt-get install -y libxml2-dev
    RUN apt-get install -y libpcre3 libpcre3-dev
    RUN apt-get install -y freetds-dev
    # RUN apt-get install -y openjdk-7-jdk
    RUN apt-get install -y software-properties-common
    
    RUN mkdir -p /mnt/s3b
    
    RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
    
    RUN cd ~/
    RUN /bin/bash -l -c "wget https://github.com/s3fs-fuse/s3fs-fuse/archive/master.zip"
    RUN unzip master.zip
    RUN cd s3fs-fuse-master/ && ./autogen.sh && ./configure --prefix=/usr --with-openssl && make && make install
    
    ADD templates/setup.sh /root/setup.sh
    RUN chmod +x /root/setup.sh
    
    ADD templates/backup-cron /etc/cron.d/backup-cron
    RUN chmod 0644 /etc/cron.d/backup-cron
    RUN cron
    # RUN chmod +x /root/backup-cron
    
    EXPOSE 3306
    
    CMD ["/bin/bash", "-l", "-c", "/root/setup.sh"]
    

    Here is the setup.sh file

    #!/bin/bash
    export MYSQL_HOST_IP=`awk 'NR==1 {print $1}' /etc/hosts`
    
    set -e
    set -x
    
    # NOW=$(date +"%Y-%m-%d-%H%M")
    
    # DUMP_FILE="/dumps/dump.sql"
    
    echo $AWS_S3 >> ~/.passwd-s3fs && cp ~/.passwd-s3fs /etc/passwd-s3fs
    
    chmod 600 ~/.passwd-s3fs
    chmod 640 /etc/passwd-s3fs
    
    mysql -h$MYSQL_HOST_IP -uroot -p$MYSQL_ROOT_PASSWORD -e "DROP DATABASE IF EXISTS $MYSQL_DATABASE; CREATE USER '$MYSQL_USER'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD'; CREATE DATABASE $MYSQL_DATABASE; GRANT ALL ON $MYSQL_DATABASE.* TO '$MYSQL_USER'@'localhost'; FLUSH PRIVILEGES;"
    

    Here is the docker run command:

    docker run --name=mysql-s3 --env MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} --env MYSQL_USER=${MYSQL_USER} --env MYSQL_PASSWORD=${MYSQL_PASSWORD} --env MYSQL_DATABASE=${MYSQL_DATABASE} --env AWS_S3=${AWS_S3} --detach --publish 3306:3306 --volume=/vagrant/scripts/dumps/:/dumps/ --cap-add mknod --cap-add sys_admin --device=/dev/fuse --privileged mysql-s3
    

  • php-fpm & nginx in separated docker container, can not execute .php file
  • Container keeps restarting when trying to run consul agent as docker container
  • Failed to allocate gateway with docker stack
  • how to rsync from a docker container to my host computer
  • how to connect to port on the host from the container
  • What is the correct ENTRYPOINT for Asp.net Core RC2 Dockerfile
  • One Solution collect form web for “Custom Docker MySQL build won't run”

    This approach seems too complicated using fuse and modifying the base mysql container. I would suggest that you just stick with the base MYSQL and write a script that you run in a separate container that does a MYSQL dump to a text file and then copies that text file to S3 with the AWS CLI.

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