MacOs中的Docker非常慢 [英] Docker in MacOs is very slow
问题描述
我有这个docker-compose.yml:
I have this docker-compose.yml:
version: "3.1"
services:
memcached:
image: memcached:alpine
container_name: universal-memcached2
redis:
image: redis:alpine
container_name: universal-redis2
mariadb:
image: mariadb:10.4
container_name: universal-mariadb2
working_dir: /application
volumes:
- .:/application
- "../data/db:/var/lib/mysql" # skasowac
environment:
- MYSQL_ROOT_PASSWORD=Haslo
- MYSQL_DATABASE=sample
- MYSQL_USER=user
- MYSQL_PASSWORD=Haslo
ports:
- "8083:3306"
webserver:
image: nginx:alpine
container_name: universal-webserver2
working_dir: /application
volumes:
- .:/application
- ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "8080:80"
php-fpm:
build: phpdocker/php-fpm
container_name: universal-php-fpm2
working_dir: /application
volumes:
- .:/application
- ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.3/fpm/conf.d/99-overrides.ini
volumes:
generated:
var:
static:
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- mariadb
environment:
PMA_HOST: mariadb
PMA_PORT: 3306
ports:
- '8081:80'
当我在symfony 4中运行我的最新项目时,它的运行速度非常慢...:(
When I run my newest project in symfony 4 on it, it works very slowly... :(
我有新的MacO和Docker桌面. 我目前正在学习Symfony和Laravel框架,但这对于Docker来说非常慢.它甚至都没有工作.
I have new MacOs and Docker Desktop. I'm currently learning the Symfony and Laravel framework, but this is very slow for Docker. It is not even working on it.
我该如何修理?
推荐答案
事实上,Docker需要一个普通的Linux内核才能运行.不幸的是,Mac OS和Windows无法提供此功能.因此,Mac OS上有一个客户端来运行Docker.除此之外,Mac OS内核和应用程序(Docker容器)之间还有一个抽象层,文件系统也不相同.因此,Docker在Mac OS上运行缓慢.您无法在Mac OS(如Linux)上运行Docker.
As a matter of fact, Docker needs a plain Linux kernel to run. Unfortunately, Mac OS and Windows cannot provide this. Therefore, there is a client on Mac OS to run Docker. In addition to this, there is an abstraction layer between Mac OS kernel and applications (Docker containers) and the filesystems are not the same. Because of that, Docker runs on Mac OS slowly. You are not able to run the Docker on Mac OS like on Linux.
如果我需要提供一些有关实际用例的实例.我有同一台机器.因此,我在Mac OS Mojave的Docker v18上使用Symfony 4.这是我的Symfony在Docker上的总执行时间. (很明显,这取决于您的前端和数据库查询,但我尝试向您介绍主要逻辑.)
If I need to give some instances about real use-cases. I have the same machine. So, I use Symfony 4 on Docker v18 on Mac OS Mojave. This is my Symfony total execution time on Docker. (Obviously, it depends on your frontend and database queries but I try to enlighten you for main logic.)
- 第一次渲染12000毫秒
- 使用Symfony缓存:344毫秒
- 使用Docker缓存(:Docker的卷的cached属性):195毫秒
只要我在不使用Docker的情况下使用Symfony,以下是我的总执行时间.
As long as I use Symfony without Docker, the following is my total execution time.
- 没有Docker,带有Symfony缓存:82毫秒
鉴于此,我们可以做一些改进以获得更好的工作空间.例如,您可以使用这样的卷,
Whereas, we could do some improvements to get better workspace. For example, you can use volumes like this,
volumes:
- .:/application:cached
这篇关于MacOs中的Docker非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!