Home > PHP Framework > Workerman > How to run workerman on docker?

How to run workerman on docker?

青灯夜游
Release: 2021-02-01 12:02:18
forward
6100 people have browsed it

How to run workerman on docker? The following article will introduce to you how to run workerman with docker. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to run workerman on docker?

Related recommendations: "workerman Tutorial"

Deploy the gatawayWorker project on docker, and use mysql and redis## in the project

#Install mysql

Pull the image

docker pull mysql:5.7
Copy after login
Run the container

docker run  -d  -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root --name m_mysql mysql:5.7
Copy after login
-d run in the background

-p port mapping, the front is the host port, the back Is the container port that needs to be mapped
-e Set the environment variable, MYSQL_ROOT_PASSWORD is the initial password of the mysql root user
--name is the only name of the container

Enter the container

docker exec -it m_mysql /bin/bash
Copy after login
OptionsOption abbreviationDescription##–detach–interactive–ttymysql remote connection settings
-d Run the container in the background and print the container ID.
-i Keep standard input open even if there is no connection, usually used with -t.
-t Allocates a pseudo-tty, usually used with -i.
mysql -uroot -proot
use mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Copy after login

This way you can connect through the public network

Install php

Pull Mirror

docker pull php:7.3-cli
Copy after login

Run

docker run --name myphp -p 8282:8282 -v /home/wwwroot:/www -d php:7.3-fpm
Copy after login

-p Add host to container port mapping to map the 8282 that needs to be used. Multiple ports can be used multiple times -p

-v Add directory Mapping Put the project under /home/wwwroot, and the environment required to install workererman will automatically appear in the container


apt-get install libevent-dev
Copy after login
apt-get install libevent-dev
docker-php-ext-install pcntl sockets
docker-php-ext-install event
docker-php-ext-install pdo_mysql
docker-php-ext-install redis
Copy after login
Start workererman

php start.php start -d
Copy after login

For more programming-related knowledge, please visit: Introduction to Programming

! !

The above is the detailed content of How to run workerman on docker?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template