Difference between revisions of "Manual container creation"
From Tech-Wiki
Line 27: | Line 27: | ||
Allow from All | Allow from All | ||
Require all granted | Require all granted | ||
− | + | </Directory> | |
</VirtualHost> | </VirtualHost> | ||
ServerName localhost | ServerName localhost | ||
Line 37: | Line 37: | ||
Then you can run this container using the compose file below: | Then you can run this container using the compose file below: | ||
− | version: '2' | + | version: '2' |
− | services: | + | services: |
− | + | myproject: | |
− | + | build: ./ | |
− | + | container_name: my_project | |
− | + | restart: always | |
− | + | networks: | |
− | + | - docker-localhost | |
− | + | ports: | |
− | + | - 80:80 | |
− | networks: | + | networks: |
− | + | docker-localhost: |
Revision as of 14:27, 7 April 2020
If you need to create a custom container image, adding your own packages, create a Dockfile as follows:
FROM ulsmith/debian-apache-php LABEL Edwin [email protected] RUN echo "deb http://ftp.de.debian.org/debian stretch main" >> /etc/apt/sources.list RUN apt-get update RUN apt-get install -y python bash RUN apt-get clean -y EXPOSE 80 CMD ["/start.sh"]
start.sh
#!/bin/bash source /etc/apache2/envvars exec apache2 -D FOREGROUND
site.conf
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html <Directory /var/www/html> Options FollowSymLinks AllowOverride All Order allow,deny Allow from All Require all granted </Directory> </VirtualHost> ServerName localhost ServerSignature Off ServerTokens Prod
The image based on Dockfile file above can be generated by the command below
docker image build -t container1 .
Then you can run this container using the compose file below:
version: '2' services: myproject: build: ./ container_name: my_project restart: always networks: - docker-localhost ports: - 80:80 networks: docker-localhost: