Hi,
I would like to copy my /etc/mysql/my.cnf in order to config MySQL with:
test-phpunit:
docker:
- image: circleci/php:7.0-cli
- image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
volumes:
- .circleci/my.cnf:/etc/mysql/my.cnf
But this doesn’t seems to work, how could I do this ?
Thanks
Just to make sure I understand, you’re trying to copy your my.cnf file from your main container (circleci/php) to your mysql container?
Assuming that’s the case, then you’re probably going to have a problem because at the point that you’re spinning up your containers, you haven’t checked your code out yet. Once you reach that step, you’ll no longer be able to use the docker daemon thread to move files between containers. I had a similar problem… I ended up using a machine build and then starting up my docker containers myself. I could then move files freely between them with the “docker cp” command. Here’s an example of what your configuration could look like:
jobs:
build:
machine: true
steps:
- checkout
- run:
name: Start containers
command: docker run --name mysqlcontainer -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=test -d mysql:5.7
- run:
name: Move config file
command: docker cp /etc/mysql/my.cnf mysqlcontainer:/etc/mysql/my.cnf