用php和mysql创builddocker镜像

我有build立在ubuntu和mysql上的php5.6-apache映像 :5.6映像 。 我想从两幅图像上面创builddocker图像,以便我可以在gitlab ci中使用新build的图像。 我怎样才能做到这一点? 我对docker和gitlab相当新。

我试图在gitlab中,但没有工作。

image: viraths/php5.6-apache:latest stages: - build - test deps build: stage: build variables: MYSQL_DATABASE: test MYSQL_ROOT_PASSWORD: password DNSDOCK_ALIAS: localhost services: - mysql:5.6 script: - export APPLICATION_ENV=test - if [ -f /.dockerinit ]; then export COMPOSER_HOME=/cache/composer; fi; - php -v - composer install --no-progress --no-interaction --prefer-dist artifacts: paths: - vendor/ expire_in: 1 week tags: - docker 

在gitlab ci中运行composer安装时出现以下错误。

 [Doctrine\DBAL\Exception\ConnectionException] An exception occured in driver: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 

您没有正确configuration数据库。 使用你的configurationmysql可以在主机mysql3306端口上使用。 相反,您的应用程序正在通过unix套接字尝试本地连接。 configuration连接,所有应该工作。