简体   繁体   English

Docker 运行 php 脚本

[英]Docker run php script

I have some script for irc bot and want to run it with docker run -d --name php-fpm php:5 irc_bot.php however it doesn't work.我有一些 irc bot 脚本,想用docker run -d --name php-fpm php:5 irc_bot.php运行它,但是它不起作用。 I don't need web server : apach, nginx, but only clli is needed.我不需要网络服务器:apach、nginx,但只需要 clli。

Do you know how to simply run php irc_bot.php with online docker command?您知道如何使用在线php irc_bot.php命令简单地运行php irc_bot.php吗?

The main thing you're missing appears to be a volume.您缺少的主要内容似乎是一卷。 The container doesn't actually have a "irc_bot.php", so you probably need something like...容器实际上没有“irc_bot.php”,因此您可能需要类似...

docker run -d -v /directory/with/file/:/dir/to/run/from/ php:5.6-cli php /dir/to/run/from/irc_bot.php

The -v mounts the first path as a volume on the container so you have access to all the files inside the container, then the end part is simply the command you want to run. -v 将第一个路径作为容器上的卷挂载,以便您可以访问容器内的所有文件,然后结束部分只是您要运行的命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM