通过 docker inspect 命令,我们可以获取镜像的详细信息,其中,包括创建者,各层的数字摘要等。
https://developpaper.com/the-method-of-using-nginx-to-proxy-multiple-application-sites-in-docker/
连接问题
容器之间可以通过容器名称来连接,如nginx配置文件中连接php的代码fastcgi_pass php_container_name:9000,网站数据库配置文件使用mysql_container_name:3306。
docker exec
在已运行容器中执行命令
docker exec -w /user/work/ container_name pwd
参数解释
-w 在容器中的工作路径
docker exec -ti container_name bash
参数解释
-i 进入交互模式
-t 分配伪tty
参考资料
https://docs.docker.com/engine/reference/commandline/exec/
dnmp环境
https://github.com/yeszao/dnmp
docker 常用命令
垃圾内存清理
查看镜像、容器、数据卷所占用的空间
$ docker system df
$ docker system prune
http://tech.osteel.me/posts/2017/01/15/how-to-use-docker-for-local-web-development-an-update.html
参考资料
https://vagrantcloud.com/zspencer/boxes/centos7-docker-host/versions/0.1.0
http://dockerpool.com/static/books/docker_practice/basic_concept/repository.html
keep docker image small
https://developers.redhat.com/blog/2016/03/09/more-about-docker-images-size/
$ cd /your/project/directory
$ vagrant init zspencer/centos7-docker-host # Use this in your projects Vagrantfile
Open up the Vagrantfile and configure it as desired.
For an example of how to configure your Vagrantfile, see:
https://github.com/zspencer/packager/blob/0.1.0/Vagrantfile
mv docker-php-ext-xdebug.ini docker-php-ext-xdebug.ini.disable
$ vagrant up # Starts the Vagrant machine
$ vagrant ssh # Connect into the VM to run docker-related commands
Q:为了让php56支持sftp,ssh2_connect函数,
A:stack overflow 网友提供了一种,还没有试过:Dockerfile加一行 docker-php-ext-install php-ssh2,
方法一:
Dockerfile 中加下面几行
&& apt-get install -y libssh2-1-dev libssh2-1 \
&& pecl install ssh2 \
&& docker-php-ext-enable ssh2
docker-compose -f docker-compose56.yml build
docker-compose -f docker-compose56.yml up -d
docker-compose -f docker-compose56.yml up -d --force-recreate --build php # 重新编译php 结果使用了 cache
docker-compose build --no-cache php # 重新编译php服务
docker exec -w /ubox/apps/monk/testlocal/ dnmp-php56 php -v
docker exec -it dnmp-php56 /bin/bash # 登入容器
apt-cache search php | grep ssh2 # 检查 ssh2 是否存在
docker exec dnmp-php56 apt-cache search php | grep ssh2
方法二:
# PECL
RUN docker-php-pecl-install \
ssh2-1.1.2 \
redis-4.0.2 \
apcu-5.1.11 \
memcached-3.0.4
网友评论