Answer the question
In order to leave comments, you need to log in
How does composer work in a docker container?
Actually there are two containers, base and php with scripts.
The question is, how to work with Composer manager in docker containers? Those. I put it in a container with PHP and then I need to run the composer update command manually or write it in the Dockerfile? And where to put the ssh key to access github?
In general, I have problems with the design, help me how to properly organize the work.
Answer the question
In order to leave comments, you need to log in
For project files, make a separate container project_files
, which can then be connected to php through an --volumes-from project_files
Sample Dockerfile for this container:
FROM ubuntu
RUN apt-get update && apt-get install -y git
RUN mkdir /root/.ssh/
COPY id_rsa /root/.ssh/id_rsa
# Add bitbuckets key
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts
# CLone repo
RUN git clone [email protected]:username/projectname.git /project_files
# Create volume
VOLUME /project_files
id_rsa
and build docker build -t myproject/files .
and create a containerdocker create --name project_files myproject/files /bin/true
docker pull composer/composer
You need to run it and install the dependencies of your project by connecting the container with the project files:docker run \
--name myproject_php \
--volumes-from project_files \
php:5-fpm
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question