This image was built based on the DockerHub official image. It included the required extensions for Laravel. and included some common extensions.
This image was built based-on php/apache image. Add support to Laravel's scheduled tasks, queue, and specify the execution user with $UID
and $GID
. The container will create the run user at startup.
The Apache service, scheduled tasks (by artisan schedule:run
), queue work processes (by artisan queue:work
), and any commands by artisan will run as a user with $UID
and $GID
.
# for docker
▶ docker run -d \
--restart always \
--hostname simple \
--name simple
-p 80:80 \
-e UID=$(id -u) \
-e GID=$(id -g) \
-e SCHEDULE=On \
-e SUPERVISORD=On \
-v /path/to/your/php.ini:/usr/local/etc/php/php.ini \
-v /path/to/host:/var/www/html \
troytse/php-laravel:apache
# for podman
▶ podman run -d \
--restart always \
--hostname simple \
--name simple
-p 80:80 \
-e UID=$(id -u) \
-e GID=$(id -g) \
--uidmap 0:0:999 --gidmap 0:0:999 \
--uidmap 1000:$(id -u):1 --gidmap 1000:$(id -g):1 \
-e SCHEDULE=On \
-e SUPERVISORD=On \
-v /path/to/your/php.ini:/usr/local/etc/php/php.ini \
-v /path/to/host:/var/www/html \
quay.io/troytse/php-laravel:apache
apache
:▶ docker exec -it sample ps -aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.8 0.2 223304 32828 ? Ss 10:27 0:00 apache2 -DFOREGROUND
root 47 0.0 0.0 5512 2060 ? Ss 10:27 0:00 /usr/sbin/cron
contain+ 58 0.0 0.0 223336 10068 ? S 10:27 0:00 apache2 -DFOREGROUND
contain+ 59 0.0 0.0 223336 10068 ? S 10:27 0:00 apache2 -DFOREGROUND
contain+ 60 0.0 0.0 223336 10068 ? S 10:27 0:00 apache2 -DFOREGROUND
contain+ 61 0.0 0.0 223336 10068 ? S 10:27 0:00 apache2 -DFOREGROUND
contain+ 62 0.0 0.0 223336 10068 ? S 10:27 0:00 apache2 -DFOREGROUND
root 65 0.0 0.1 26204 16452 ? Ss 10:27 0:00 /usr/bin/python2 /usr/bin/supervisord -c /var/local/etc/supervisord.conf
contain+ 66 1.0 0.2 107956 46652 ? S 10:27 0:00 /usr/local/bin/php /var/www/html/artisan queue:work --daemon --queue=default,high
contain+ 67 0.9 0.2 107956 46636 ? S 10:27 0:00 /usr/local/bin/php /var/www/html/artisan queue:work --daemon --queue=default,high
contain+ 68 1.0 0.2 107956 46968 ? S 10:27 0:00 /usr/local/bin/php /var/www/html/artisan queue:work --daemon --queue=default,high
contain+ 70 0.9 0.2 107956 46636 ? S 10:27 0:00 /usr/local/bin/php /var/www/html/artisan queue:work --daemon --queue=low
contain+ 71 0.9 0.2 107956 46636 ? S 10:27 0:00 /usr/local/bin/php /var/www/html/artisan queue:work --daemon --queue=low
root 99 0.0 0.0 7640 2732 pts/0 R+ 10:27 0:00 ps -aux
This image was built based-on php/fpm-alpine image. Add support to Laravel's scheduled tasks, queue, and specify the execution user with $UID
and $GID
. The container will create the run user at startup.
The PHP-FPM processes, scheduled tasks (by artisan schedule:run
), queue work processes (by artisan queue:work
), and any commands by artisan will run as a user with $UID
and $GID
.
# for docker
▶ docker run -d \
--restart always \
--hostname sample \
--name sample \
-p 9000:9000 \
-e UID=$(id -u) \
-e GID=$(id -g) \
-e SCHEDULE=On \
-e SUPERVISORD=On \
-v /path/to/your/php.ini:/usr/local/etc/php/php.ini \
-v /path/to/host:/var/www/html \
troytse/php-laravel:fpm-alpine
# for podman
▶ podman run -d \
--restart always \
--hostname sample \
--name sample \
-p 9000:9000 \
-e UID=$(id -u) \
-e GID=$(id -g) \
--uidmap 0:0:999 --gidmap 0:0:999 \
--uidmap 1000:$(id -u):1 --gidmap 1000:$(id -g):1 \
-e SCHEDULE=On \
-e SUPERVISORD=On \
-v /path/to/your/php.ini:/usr/local/etc/php/php.ini \
-v /path/to/host:/var/www/html \
quay.io/troytse/php-laravel:fpm-alpine
fpm-alpine
:▶ docker exec -it sample ps -a
sample:/var/www/html# ps -A
PID USER TIME COMMAND
1 root 0:00 php-fpm: master process (/usr/local/etc/php-fpm.conf)
25 root 0:00 /usr/local/bin/supercronic /usr/local/etc/crontab.txt
36 containe 0:00 php-fpm: pool www
37 containe 0:00 php-fpm: pool www
38 root 0:00 {supervisord} /usr/bin/python3 /usr/bin/supervisord -c /usr/local/etc/supervisord.conf
39 containe 0:00 /usr/local/bin/php /var/www/html/artisan queue:work --daemon --queue=default,high
40 containe 0:00 /usr/local/bin/php /var/www/html/artisan queue:work --daemon --queue=default,high
41 containe 0:00 /usr/local/bin/php /var/www/html/artisan queue:work --daemon --queue=default,high
42 containe 0:00 /usr/local/bin/php /var/www/html/artisan queue:work --daemon --queue=low
43 containe 0:00 /usr/local/bin/php /var/www/html/artisan queue:work --daemon --queue=low
92 root 0:00 ps -A
(Default: 0)
$UID
and $GID
will override the $APACHE_RUN_USER
and $APACHE_RUN_GROUP
)(On/Off, Default: Off)
(On/Off, Default: Off)
(Optional)
[program:queue-work-default]
process_name=%(program_name)s_%(process_num)02d
directory=/var/www/html
command=/usr/local/bin/php /var/www/html/artisan queue:work --daemon --queue=default,high
autostart=true
autorestart=true
user=%(ENV_RUN_USER)s
numprocs=3
redirect_stderr=true
[program:queue-work-low]
process_name=%(program_name)s_%(process_num)02d
directory=/var/www/html
command=/usr/local/bin/php /var/www/html/artisan queue:work --daemon --queue=low
autostart=true
autorestart=true
user=%(ENV_RUN_USER)s
numprocs=2
redirect_stderr=true
For other environment variables, please reference to the base image
Run artisan command in the container.
▶ docker/podman exec -it <container_name> artisan <command>
Run composer command in the container.
▶ docker/podman exec -it <container_name> composer <command>
You can create a shell script in your project directory to quickly call them.
#!/bin/sh
sudo docker exec -it your_container_name $@
#!/bin/sh
podman exec -it your_container_name $@
▶ ./container_exec artisan make:job DoSomething
▶ ./container_exec composer dump-autoload
$UID
and $GID
.)[PHP Modules]
bcmath
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
imap
intl
json
ldap
libxml
mbstring
memcached
msgpack
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
swoole
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。