Reputation: 5494
I use a pretty easy docker setup that includes docker-compose and docker-sync. I have the following files:
docker-compose-dev.yml
version: "2"
services:
apache:
volumes:
- ./docker-config/vhost:/etc/apache2/sites-enabled/000-default.conf
- rr-sync:/var/www/html:nocopy # nocopy is important
volumes:
rr-sync:
external: true
docker-compose.yml
version: '2'
services:
apache:
image: bylexus/apache-php7
ports:
- 80:80
db:
image: orchardup/mysql
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: rr
docker-sync.yml
version: "2"
options:
verbose: true
syncs:
rr-sync: # tip: add -sync and you keep consistent names as a convention
src: './src'
sync_excludes: ['.git']
The image that I use is bylexus/apache-php7
and it has no support for curl nor I have a tool like vim installed in the container.
The question is, how can I install curl and vim but keep using this image for apache? What do I need to change in the files above?
Thanks.
Upvotes: 3
Views: 14995
Reputation: 51768
You can do one of two things:
FROM bylexus/apache-php7
RUN apt-get update && \
apt-get dist-upgrade -y && \
apt-get install -y \
curl \
vim
The you build this image and use it inside the composefile
docker-compose exec apache bash
And then install the tools that you want. Note in this case you will need to do that again if you remove the container and then create
(you can use volumes to mitigate this however the executables are soft linked from say /usr/bin/vim
to other dirs, so you will have to use volume for each one of these directories containing the executable links
or redirect the links directly...)
Upvotes: 0
Reputation: 37994
Add your own Dockerfile
to the project that builds on your desired base image. In this file, add your own packages (for example, curl and vim):
FROM bylexus/apache-php7
RUN apt-get install -y curl vim
Then, in your docker-compose.yml
file, do not use the image
property, but the build
property, instead:
version: '2'
services:
apache:
build: .
ports:
- 80:80
bylexus/apache-php7
image in this case is built on the ubuntu:16.10
image (as can be seen in the respective Dockerfile
), so you can use Ubuntu's package management tools. Images other than the bylexus/apache-php7
one might use other base distributions with other package managers).
Upvotes: 10