0

I have a docker-compose.yml that sets up an API service, a test MYSQL database, and a java task worker app. I then run API integration tests against the local stack. Each time I run it, I execute docker-compose rm -v to ensure that my DB is the same for each test run.

Locally, my docker-compose file sets up my images properly.

In Jenkins, using the same docker-compose file, I get the above error, copied here:

0mERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'root'@'%'

It appears something might be going on with the hostname of the image.

Here's the Dockerfile for my DB setup:

FROM mysql

ENV MYSQL_DATABASE="db_name"
ENV MYSQL_USER="user"
ENV MYSQL_PASSWORD="password1"
ENV MYSQL_ROOT_PASSWORD="password"
COPY *.sql /docker-entrypoint-initdb.d/

EXPOSE 3306

Here's my docker-compose.yml:

web-api:
    image: registry/api-repo
    links:
        - test-db
    ports:
        - "8625:8625"
    environment: 
        - MYSQL_DATABASE=db_name
        - MYSQL_HOST=test-db
        - MYSQL_USER=user
        - MYSQL_PASSWORD=password1

custodial-java:
    image: registry/java-repo
    links:
        - test-db
    environment: 
        - MYSQL_DATABASE=db_name
        - MYSQL_HOST=test-db
        - MYSQL_USER=user
        - MYSQL_PASSWORD=password1

test-db:
    image: registry/test-db
    ports:
        - "3306:3306"

I am likely missing something in my Jenkins config, but I'm not sure where to look.

1 Answers1

0

As it turned out, the version of Docker on Jenkins was not the same as my local machine. On my local machine, i was using Docker 17.03, whereas the Jenkins box was running Docker Toolbox 1.5.

After updating the build machine to use the latest docker toolbox (1.12 i believe), I no longer get this error and my automation test functions!