ENV GPG_KEYS 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3
RUN set -xe \
&& for key in $GPG_KEYS; do \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
done
ENV PHP_VERSION 5.6.15
--enable-mysqlnd is included below because it's harder to compile after the fact the extensions are (since it's a plugin for several extensions, not an extension in itself)
5 个回复
zjumoon - 蘑菇街-牧白 mubai@mogujie.com
赞同来自: 田舍先生
不能运行netstat和ifconfig是因为镜像里缺少 net-tools这个包(正如3楼 田舍先生 所说)。在Dockerfile里可以写上进行安装。 如果想3楼@田舍先生 说的 安装失败,那需要检查下镜像里的yum源,可以先启动个网络正常的容器,用同样的yum源(/etc/yum.repo.d/),试一下是否能yum info net-tools是否可以看到
root2000xyz
赞同来自:
你的docker debian镜像中没有安装 支持这些命令的工具包
SeSa _Hasaki - 用友集团iUAP中心技术研究员
赞同来自:
docker镜像重要的是轻量,所基于的系统基础镜像都是简化的,很多命令都没有,想用某些命令的话可以自己安装,嫌麻烦的话可以安装好一个容器之后再commit成镜像,以后直接用就行了。容器内服务没起来是因为本来就不是自启动的,除非你写在了开始运行的脚本里启动。
田舍先生
赞同来自:
谢谢你们的支持。通过Dockerfile,安装一个net-tools就解决了。不过,始终没法安装。
如果哪们同学解决了,希望共享下。
<pre>
FROM debian:jessie
安装ssh服务
Install packages
RUN apt-get update && \apt-get -y install openssh-server pwgen && \
mkdir -p /var/run/sshd && \
sed -i "s/UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config && \
sed -i "s/PermitRootLogin without-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
ADD set_root_pw.sh /set_root_pw.sh
ADD run.sh /run.sh
RUN chmod +x /*.sh
ENV AUTHORIZED_KEYS <span>None<span>
安装相关工具
RUN apt-get update && apt-get install net-toolsRUN apt-get update && apt-get install vim
persistent / runtime deps
RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/*phpize deps
RUN apt-get update && apt-get install -y autoconf file g++ gcc libc-dev make pkg-config re2c --no-install-recommends && rm -r /var/lib/apt/lists/*ENV PHP_INI_DIR /usr/local/etc/php
RUN mkdir -p $PHP_INI_DIR/conf.d
<span><autogenerated><span>
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data
<span></autogenerated><span>
ENV GPG_KEYS 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3
RUN set -xe \
&& for key in $GPG_KEYS; do \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
done
ENV PHP_VERSION 5.6.15
--enable-mysqlnd is included below because it's harder to compile after the fact the extensions are (since it's a plugin for several extensions, not an extension in itself)
RUN buildDeps=" \$PHP_EXTRA_BUILD_DEPS \
libcurl4-openssl-dev \
libreadline6-dev \
librecode-dev \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
xz-utils \
" \
&& set -x \
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
&& curl -SL "http://php.net/get/php-$PHP_VERSION.tar.xz/from/this/mirror" -o php.tar.xz \
&& curl -SL "http://php.net/get/php-$PHP_VERSION.tar.xz.asc/from/this/mirror" -o php.tar.xz.asc \
&& gpg --verify php.tar.xz.asc \
&& mkdir -p /usr/src/php \
&& tar -xof php.tar.xz -C /usr/src/php --strip-components=1 \
&& rm php.tar.xz* \
&& cd /usr/src/php \
&& ./configure \
--with-config-file-path="$PHP_INI_DIR" \
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
$PHP_EXTRA_CONFIGURE_ARGS \
--disable-cgi \
--enable-mysqlnd \
--with-curl \
--with-openssl \
--with-readline \
--with-recode \
--with-zlib \
&& make -j"$(nproc)" \
&& make install \
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \
&& make clean
COPY docker-php-ext-* /usr/local/bin/
<span><autogenerated><span>
WORKDIR /var/www/html
COPY php-fpm.conf /usr/local/etc/
EXPOSE 22 9000
CMD
CMD
<span></autogenerated><span></pre>
mwyangfan
赞同来自:
Container 中是可以运行 netstat、lsof、ss 这些端口类程序的。
不能使用的原因很可能是镜像的问题(不一定是镜像的故障,可能安装和配置不够完善,比如AppArmor),下图是用 Ubuntu 和 CentOS 镜像中截取的。
希望对你有所帮助。
<div class="aw-upload-img-list active">
<a href="http://dockone.io/uploads/answ ... ot%3B target="_blank" data-fancybox-group="thumb" rel="lightbox"><img src="http://dockone.io/uploads/answ ... ot%3B class="img-polaroid" title="netstat.png" alt="netstat.png" /></a>
</div>