问题描述
通过本演练,我在创建一系列允许我使用MySQLI,PHP和phpmyadmin的docker容器之后获得了成功:
I had previous success following this walkthrough on creating a series of docker containers that allowed me to use MySQLI, PHP, and phpmyadmin:
我决定再次尝试并做一些调整,例如尝试使用PDO代替MYSQLI。
I decided to try it again and make a few tweaks, such as trying to PDO instead of MYSQLI.
从docker-compose.yml文件开始:
Starting with the docker-compose.yml file:
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:
Here is my Dockerfile:
FROM php:7.0.30-apache
RUN docker-php-ext-install pdo pdo_mysql
现在,如果您参考上面的教程链接,则更改了myDb.sql文件。我创建了一个名为 users的表,而不是创建一个名为 Person的表。我不想粘贴整个myDb.sql文件,但这是CREATE TABLE部分:
Now if you'll reference the tutorial link above, I altered the myDb.sql file. Instead of creating the table called 'Person', I created a table called 'users'. I did not want to paste the whole myDb.sql file, but here is the CREATE TABLE portion:
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', '[email protected]', 'Engineering', 'Ensign', '7577771212', NOW(), 'admin');
我还添加了另一个我将不包括的创建表脚本,因为这个问题越来越长。
I also added another create table script that I won't include, as this question is getting long.
运行命令 docker-compose up时,出现以下错误:
Upon running the command 'docker-compose up', I receive the following error:
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
我不确定为什么会这样我要运行我什至不确定为什么错误消息指出我使用了错误的名称或密码。
I am not sure why this is failing to run. I am not even sure why the error message states that I am using the wrong name or passphrase.
我缺少什么或需要解决什么才能使其正常运行?
What am I missing or what do I need to fix that will get this to run properly?
推荐答案
这是docker build的问题; cos,在您的情况下docker hub登录必须失败(配置文件中的多个docker登录注册表可能会发生这种情况)
It is an issue with docker build; cos, the docker hub login must fail in your case (this might have happened with multiple docker login registry in your config file)
如果您想快速修复,请删除 .docker / config.json
文件并登录docker,然后再运行 docker-compose up
If you want a quick fix, delete the .docker/config.json
file and login docker before you run docker-compose up
sudo rm ~/.docker/config.json
docker login
docker-compose up
注意:一个新的〜/ .docker / config.json
文件将在您成功登录后创建
Note: a new ~/.docker/config.json
file will be created on your successful login
这篇关于docker-compose无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!