docker-compose无法启动

时间:2019-05-23 03:57:33

标签: docker docker-compose

通过本演练,我成功创建了一系列允许我使用MySQLI,PHP和phpmyadmin的docker容器:

https://gist.github.com/jcavat/2ed51c6371b9b488d6a940ba1049189b

我决定再次尝试并做一些调整,例如尝试使用PDO代替MYSQLI。

从docker-compose.yml文件开始:

version: "3.7"
services:
www:
    build: .
    ports: 
        - "8001:80"
    volumes:
        - ./www:/var/www/html/
    links:
        - db
    networks:
        - default
db:
    image: mysql:5.7.13
    ports: 
        - "3306:3306"
    environment:
        MYSQL_DATABASE: myDb
        MYSQL_USER: user
        MYSQL_PASSWORD: test
        MYSQL_ROOT_PASSWORD: test
    volumes:
        - ./dump:/docker-entrypoint-initdb.d
        - persistent:/var/lib/mysql
    networks:
        - default
phpmyadmin:
    image: phpmyadmin/phpmyadmin
    links: 
        - db:db
    ports:
        - 8000:80
    environment:
        MYSQL_USER: user
        MYSQL_PASSWORD: test
        MYSQL_ROOT_PASSWORD: test
volumes:
  persistent:

这是我的Dockerfile:

FROM php:7.0.30-apache 
RUN docker-php-ext-install pdo pdo_mysql

现在,如果您参考上面的教程链接,则更改了myDb.sql文件。我创建了一个名为“ users”的表,而不是创建一个名为“ Person”的表。我不想粘贴整个myDb.sql文件,但这是CREATE TABLE部分:

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `firstName` varchar(30) NOT NULL,
  `lastName` varchar(50) NOT NULL,
  `username` varchar(20) NOT NULL,
  `email` varchar(100) NOT NULL,
  `department` varchar(50) NOT NULL,
  `title` varchar(30),
  `phone` varchar(30),
  `addDate` datetime(),
  `addUser` varchar(30) NOT NULL,
  `lastLogin` datetime()
) ENGINE=InnoDB DEFAULT CHARSET=latin1; 

然后插入:

INSERT INTO `users` (`id`, `firstName`, `lastName`, `username`, `email`, `department`, `title`, `phone`, `addDate`, `addUser`) VALUES (1, 'William', 'Wheaton', 'usa.wwheaton', 'usa.wwheaton@gmail.com', 'Engineering', 'Ensign', '7577771212', NOW(), 'admin');   

我还添加了另一个我将不包含的创建表脚本,因为这个问题越来越长。

运行命令“ docker-compose up”时,出现以下错误:

Building www
Traceback (most recent call last):
  File "site-packages/dockerpycreds/store.py", line 74, in _execute
  File "subprocess.py", line 336, in check_output
  File "subprocess.py", line 418, in run
subprocess.CalledProcessError: Command '['/usr/local/bin/docker-credential-osxkeychain', 'get']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages/docker/auth.py", line 129, in _resolve_authconfig_credstore
  File "site-packages/dockerpycreds/store.py", line 35, in get
  File "site-packages/dockerpycreds/store.py", line 87, in _execute
dockerpycreds.errors.StoreError: Credentials store docker-credential-osxkeychain exited with "The user name or passphrase you entered is not correct.".

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "docker-compose", line 6, in <module>
 File "compose/cli/main.py", line 71, in main
 File "compose/cli/main.py", line 127, in perform_command
 File "compose/cli/main.py", line 1080, in up
 File "compose/cli/main.py", line 1076, in up
 File "compose/project.py", line 475, in up
 File "compose/service.py", line 358, in ensure_image_exists
 File "compose/service.py", line 1082, in build
 File "site-packages/docker/api/build.py", line 251, in build
 File "site-packages/docker/api/build.py", line 307, in _set_auth_headers
 File "site-packages/docker/auth.py", line 96, in resolve_authconfig
 File "site-packages/docker/auth.py", line 146, in _resolve_authconfig_credstore
docker.errors.DockerException: Credentials store error: StoreError('Credentials store docker-credential-osxkeychain exited with "The user name or passphrase you entered is not correct.".',)
[49981] Failed to execute script docker-compose

我不确定为什么无法运行。我什至不知道为什么错误消息指出我使用了错误的名称或密码。

我缺少什么或者需要解决什么才能使其正常运行?

1 个答案:

答案 0 :(得分:1)

这是docker build的问题; cos,您的情况下docker hub登录必须失败(配置文件中有多个docker login注册表可能会发生这种情况)

如果要快速修复,请删除.docker/config.json文件并登录docker,然后再运行docker-compose up

sudo rm ~/.docker/config.json

docker login

docker-compose up

注意:成功登录后,将创建一个新的~/.docker/config.json文件