Access /etc/mysql/my.cnf using Docker

Solution 1:

Access the docker container using it's ID

sudo docker exec -i -t 665b4a1e17b6 /bin/bash

Navigate to /etc/mysql/my.cnf

  cd /etc/mysql/my.cnf

Install Nano text editor

apt-get install nano

Export environment variable

export TERM=xterm

Edit your file

nano my.cnf

Solution 2:

You are not supposed to edit files inside a container. You can override the file with --volume, but you should create a new container which you customize to fit your needs. Build on the container you are using like this:

FROM foo/bar:1.0
USER root
RUN sed -i -e "/^bind-address/d" /etc/mysql/my.cnf
USER mysql