开始
- [docker for Windows 下载链接](https://download.docker.com/win/stable/Docker for Windows Installer.exe)
- 配置 PHP docker 安装页面
docker 安装
基本使用
-
下载
-
sudo wget -qO- https://get.docker.com/ | sh # 可能有提示命令需要运行 sudo usermod -aG docker runoob
-
-
启动服务
-
sudo service docker start
-
安装Python
-
安装 python-pip
-
# 若是本机没有 pip sudo apt install python-pip
-
-
查看
-
sudo docker search python # 拉取 sudo docker images python:3.7 # 进入命令行 pip安装 等操作 sudo docker run -i -t python:3.7 /bin/bash # 输入 exit 退出
-
-
编辑文件 运行
-
# 运行文件 sudo docker run -v $PWD/pinyin:/usr/src/pinyin -w /usr/src/pinyin python:3.7 python test.py
-
error
安装 docker-compose
-
安装 docker-compose, 执行下面的命令,。
sudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
-
添加目录权限
sudo chmod +x /usr/local/bin/docker-compose
-
验证 docker-compose 安装是否成功
docker-compose --version
或者使用
pip install docker-compose
使用 composer
# php-fpm Dockerfile
# Install composer
#RUN curl -sS https://getcomposer.org/installer \
#| php -- --install-dir=/usr/bin/ --filename=composer
# Register the COMPOSER_HOME environment variable
ENV COMPOSER_HOME /composer
# Add global binary directory to PATH and make sure to re-export it
ENV PATH /composer/vendor/bin:$PATH
# Allow Composer to be run as root
ENV COMPOSER_ALLOW_SUPERUSER 1
# Setup the Composer installer
RUN curl -o /tmp/composer-setup.php https://getcomposer.org/installer \
&& curl -o /tmp/composer-setup.sig https://composer.github.io/installer.sig \
&& php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }"
RUN php /tmp/composer-setup.php --no-ansi --install-dir=/usr/local/bin --filename=composer --snapshot && rm -rf /tmp/composer-setup.php