- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我一直在尝试使用 Docker 和 Docker Compose 构建一个 PHP cli 容器,我想让它保持事件状态,而不需要在其中运行任何 PHP 脚本。
我已经尝试了我自己的 Dockerfile
:
FROM ubuntu:16.04
ENV PATH="/root/.composer/vendor/bin:${PATH}"
RUN apt-get update && \
apt-get -y -qq install software-properties-common \
xvfb \
locales && \
locale-gen en_US.UTF-8 && \
export LC_ALL=en_US.UTF-8 && \
export LANG=en_US.UTF-8 && \
add-apt-repository ppa:ondrej/php && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated install \
php7.1-curl \
php7.1-cli \
php7.1-bcmath \
php7.1-json \
php7.1-intl \
php7.1-mbstring \
php7.1-mcrypt \
php7.1-mysql \
php7.1-xml \
php7.1-xsl \
php7.1-zip \
curl \
git \
wget \
pkg-config && \
apt-get clean && \
apt-get autoremove && \
rm -rf /var/lib/apt/lists/*
COPY config /
RUN sh /usr/local/bin/install.sh
ENTRYPOINT bash -C '/entrypoint.sh';'bash'
CMD ["php", "-a"]
还有另一个(从 main PHP images 扩展):
FROM php:7-cli-alpine
ENV PATH="/root/.composer/vendor/bin:${PATH}"
COPY config /
RUN sh /usr/local/bin/install.sh
WORKDIR /var/wwww
CMD ["php", "-a"]
docker-compose.yml
只有这个:
version: '3.3'
services:
webserver:
build:
context: .
restart: on-failure
env_file: .env
environment:
UID: ${UID}
GID: ${GID}
最后here是包含所有内容的完整存储库,如果您想尝试一下。
问题是什么?通过运行 docker-compose up --build --force-recreate
构建容器后,它以代码 0
退出,但 docker-composer logs
也没有帮助,因为它什么也没说。
查看命令行的以下输出(对于本文中的第二个 Dockerfile,因为第一个与更多内容几乎相同):
$ docker-compose up --build --force-recreate
Building webserver
Step 1/6 : FROM php:7-cli-alpine
7-cli-alpine: Pulling from library/php
90f4dba627d6: Pull complete
623a0217e4bc: Pull complete
ecbf507e7e3c: Pull complete
79a82dee0025: Pull complete
457716c6bb05: Pull complete
62e36287ffd0: Pull complete
507e98c003bc: Pull complete
b25e699baa37: Pull complete
Digest: sha256:ecae911bd22279d4883ffdc631afddc434641c67eedf49914fc62dafb5329663
Status: Downloaded newer image for php:7-cli-alpine
---> 1e563ea5f552
Step 2/6 : ENV PATH "/root/.composer/vendor/bin:${PATH}"
---> Running in 29b65c1d7def
---> d11c62bb5cf5
Removing intermediate container 29b65c1d7def
Step 3/6 : COPY config /
---> e42022d1de91
Step 4/6 : RUN sh /usr/local/bin/install.sh
---> Running in 749230f42e9e
All settings correct for using Composer
Downloading...
Composer (version 1.5.2) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
Changed current directory to /root/.composer
Loading composer repositories with package information
Updating dependencies
Package operations: 21 installs, 0 updates, 0 removals
- Installing hirak/prestissimo (0.3.7): Downloading (100%)
- Installing symfony/stopwatch (v3.3.10): Downloading (100%)
- Installing symfony/process (v3.3.10): Downloading (100%)
- Installing symfony/polyfill-php72 (v1.5.0): Downloading (100%)
- Installing paragonie/random_compat (v2.0.11): Downloading (100%)
- Installing symfony/polyfill-php70 (v1.5.0): Downloading (100%)
- Installing symfony/options-resolver (v3.3.10): Downloading (100%)
- Installing symfony/finder (v3.3.10): Downloading (100%)
- Installing symfony/filesystem (v3.3.10): Downloading (100%)
- Installing symfony/event-dispatcher (v3.3.10): Downloading (100%)
- Installing psr/log (1.0.2): Downloading (100%)
- Installing symfony/debug (v3.3.10): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.5.0): Downloading (100%)
- Installing symfony/console (v3.3.10): Downloading (100%)
- Installing php-cs-fixer/diff (v1.1.0): Downloading (100%)
- Installing gecko-packages/gecko-php-unit (v2.2): Downloading (100%)
- Installing doctrine/lexer (v1.0.1): Downloading (100%)
- Installing doctrine/annotations (v1.5.0): Downloading (100%)
- Installing composer/semver (1.4.2): Downloading (100%)
- Installing friendsofphp/php-cs-fixer (v2.7.1): Downloading (100%)
- Installing squizlabs/php_codesniffer (3.1.0): Downloading (100%)
Writing lock file
Generating optimized autoload files
Cache directory does not exist (cache-vcs-dir):
Clearing cache (cache-repo-dir): /root/.composer/cache/repo
Clearing cache (cache-files-dir): /root/.composer/cache/files
Clearing cache (cache-dir): /root/.composer/cache
All caches cleared.
---> ff310362f4a5
Removing intermediate container 749230f42e9e
Step 5/6 : WORKDIR /var/wwww
---> fe10fd52d6b6
Removing intermediate container 6e472a693c0c
Step 6/6 : CMD php -a
---> Running in 789688d1346a
---> b1286e96580b
Removing intermediate container 789688d1346a
Successfully built b1286e96580b
Successfully tagged dockerlamp_webserver:latest
Recreating dockerlamp_webserver_1 ...
Recreating dockerlamp_webserver_1 ... done
Attaching to dockerlamp_webserver_1
webserver_1 | Interactive shell
webserver_1 |
dockerlamp_webserver_1 exited with code 0
$ docker-compose logs
Attaching to dockerlamp_webserver_1
webserver_1 | Interactive shell
webserver_1 |
如何在不需要运行 PHP 脚本的情况下保持容器运行?
Note: you might be asking why not just build
php-fpm|apache
but the thing is I do not need any webserver because the container will be used for a command line project only (which is a WIP)
最佳答案
您正在运行 php -a
,这是一个 REPL,它需要交互式 TTY。所以你需要在你的撰写中启用那些
version: '3.3'
services:
webserver:
build:
context: .
restart: on-failure
env_file: .env
environment:
UID: ${UID}
GID: ${GID}
tty: true
stdin_open: true
稍后如果您需要附加到它来运行命令,您将需要使用 docker
docker attach <containernameOrID>
关于php - 如何在不需要任何 PHP 脚本的情况下保持 PHP-CLI 容器运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46735302/
我有 powershell 脚本。通过调度程序,我运行 bat 文件,该文件运行 PS1 文件。 BAT文件 Powershell.exe -executionpolicy remotesigned
什么更快? 或者 $.getScript('../js/SOME.js', function (){ ... // with $.ajaxSetup({ cache: true });
需要bash脚本来显示文件 #!/bin/bash my_ls() { # save current directory then cd to "$1" pushd "$1" >/dev/nu
我有一个输入 csv 文件,实际上我需要在输入文件中选择第 2 列和第 3 列值,并且需要转换两个值的时区(从 PT 到 CT),转换后我需要替换转换后的时区值到文件。 注意: 所有输入日期值都在太平
我正在使用/etc/init.d/httpd 作为 init.d 脚本的模板。我了解文件中发生的所有内容,但以下行除外: LANG=$HTTPD_LANG daemon --pidfile=${pid
我有以下选择: python runscript.py -O start -a "-a "\"-o \\\"-f/dev/sda1 -b256k -Q8\\\" -l test -p maim\""
我对 shell 脚本完全陌生,但我需要编写一个 shell 脚本来检查文件是否存在,然后移动到另一个位置 这是我写的: 一旦设备崩溃,我就会在/storage/sdcard1/1 中收集日志 #!/
我正在使用 bash 脚本从文本文件中读取数据。 数据: 04:31 Alex M.O.R.P.H. & Natalie Gioia - My Heaven http://goo.gl/rMOa2q
这是单击按钮时运行的 javascript 的结尾 xmlObj.open ('GET', /ajax.php, true); xmlObj.send (''); } 所以这会执行根目录中的php脚本
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我需要将文件转换为可读流以通过 api 上传,有一个使用 fs.createReadStream 的 Node js 示例。任何人都可以告诉我上述声明的 python 等价物是什么? 例子 const
我有一个 shell 脚本 cron,它从同一目录调用 python 脚本,但是当这个 cron 执行时,我没有从我的 python 脚本中获得预期的输出,当我手动执行它时,我的 python 脚本的
如何使 XMLHttpRequest (ajax) 调用的 php 脚本安全。 我的意思是,不让 PHP 文件通过直接 url 运行,只能通过脚本从我的页面调用(我不想向未登录的用户显示数据库结果,并
我正在尝试添加以下内容 我正在使用经典的 asp。但我不断收到的错误是“一个脚本 block 不能放在另一个脚本 block 内。”我尝试了此处的 document.write 技术:Javasc
如何从另一个 PHP 脚本(如批处理文件)中运行多个 PHP 脚本?如果我了解 include 在做什么,我认为 include 不会起作用;因为我正在运行的每个文件都会重新声明一些相同的函数等。我想
我想创建具有动态内容的网页。我有一个 HTML 页面,我想从中调用一个 lua 脚本 如何调用 lua 脚本? ? ? 从中检索数据?我可以做类似的事情吗: int xx = 0; xx
我删除了我的第一个问题,并重新编写了更多细节和附加 jSfiddle domos。 我有一个脚本,它运行查询并返回数据,然后填充表。表中的行自动循环滚动。所有这些工作正常,并通过使用以下代码完成。然而
我尝试使用 amp 脚本,但收到此错误: “[amp-script] 脚本哈希未找到。amp-script[script="hello-world"].js 必须在元[name="amp-script
我有一个读取输入的 Shell 脚本 #!/bin/bash echo "Type the year that you want to check (4 digits), followed by [E
我正在从 nodejs 调用 Lua 脚本。我想传递一个数组作为参数。我在 Lua 中解析该数组时遇到问题。 下面是一个例子: var script = 'local actorlist = ARGV
我是一名优秀的程序员,十分优秀!