Skip to content

Instantly share code, notes, and snippets.

@4sskick
Created February 18, 2022 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4sskick/6bbc772bd25b53239a16d89dd3674c0d to your computer and use it in GitHub Desktop.
Save 4sskick/6bbc772bd25b53239a16d89dd3674c0d to your computer and use it in GitHub Desktop.
use composer via docker
I'm working on project php based (sepc. code igniter 3), which composer gonna be a tools to install dependencies/library. But i don't want to install it on my local.
so I decide to using container as my virtual environment, to do that you can see my Dockerfile on my project here https://github.com/4sskick/infra/blob/master/php-cli/Dockerfile
on the last line, I add command to run curl command to install composer that will attached on my container I'm gonna built after.
to use command composer, you can folllow this command:
- see container ID by command `docker container ls`
- if you use my project infra on my github, it would be using `docker-compose up` to run all services, then see on section ck_php there would be container ID after hit command `docker container ls`
attach the container by command `docker exec -it <container-ID> sh -c "composer --version" `
- it gonna print you the version of composer installed then exit after done
- everytime you need to use composer, you need to hit command `docker exec -it <container-ID> sh -c "command-compose-here" `
*note: FYI, the composer config you used will directly appeared on your local machine workdir you set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment