Skip to content

Commit 0572fc1

Browse files
author
l12ab
committed
将composer安装至php容器内;修改php alpine版本内的www-data账户和组id为1000。
1 parent d7ac21a commit 0572fc1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,17 @@ Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
226226
227227
```
228228
229+
**php容器内执行composer**
230+
1. 如果composer对php版本有依赖,并且composer已安装在php容器内,也可使用如下命令
231+
232+
```
233+
docker run --rm --interactive --tty \
234+
--volume $PWD:/www \
235+
--user 1000:1000 \
236+
dnmp_php \
237+
composer install
238+
```
239+
229240
## 4.添加快捷命令
230241
在开发的时候,我们可能经常使用`docker exec -it`切换到容器中,把常用的做成命令别名是个省事的方法。
231242

services/php/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ ARG PHP_EXTENSIONS
66
ARG CONTAINER_PACKAGE_URL
77

88

9+
COPY --from=composer /usr/bin/composer /usr/bin/composer
910
COPY ./extensions /tmp/extensions
1011
WORKDIR /tmp/extensions
1112

13+
# php alpine image's www-data user uid & gid are 82, change them to 1000 (primary user)
14+
RUN apk add shadow && usermod -u 1000 www-data && groupmod -g 1000 www-data
1215

1316
RUN if [ "${CONTAINER_PACKAGE_URL}" != "" ]; then \
1417
sed -i "s/dl-cdn.alpinelinux.org/${CONTAINER_PACKAGE_URL}/g" /etc/apk/repositories; \

0 commit comments

Comments
 (0)