-
Notifications
You must be signed in to change notification settings - Fork 9
Manual usage of Docker Stack
cmtickle edited this page Apr 24, 2023
·
1 revision
(All examples on this page assume that you are using Linux/Mac OS and have cloned Docker-Stack to your user home directory. The commands should be executed in a Terminal window as your own user, not root or sudo.)
Run phpinfo() with PHP 7.4 as https://my-first.localhost
This scenario demonstrates:
- The function of the
srcfolder. - How to start containers without the helper scripts.
- The stacks support for '.localhost' domains.
# Make sure we're in the right place.
cd ~/docker-stack
# Create the folder ./src/my-first.localhost/pub
mkdir -p ./src/my-first.localhost/pub
# Create index.php
echo -e "<?php\nphpinfo();" > ./src/my-first.localhost/pub/index.php
# Start the containers you require.
./bin/docker-compose up -d nginx php74You should now be able to access https://my-first.localhost (ignore errors about self-signed certificates, this is expected).
You should see details about PHP 7.4.
Change https://my-first.localhost to use PHP 8.1
This scenario demonstrates:
- Changing the PHP version of a host
- Manually refreshing/updating a container.
- Manually stopping a container.
- Edit the file ./docker/nginx/m-hosts.conf
- In the
$PHP_HOSTM2map, above the section marked "DEFAULT" add a new line. The line should saymy-first.localhost php81; - Update the Nginx container image:
./bin/docker-compose build nginx - Update the running Nginx container to use the new image:
./bin/docker-compose up -d nginx - Start the PHP 8.1 container:
./bin/docker-compose up -d php81
You should now be able to access https://my-first.localhost (ignore errors about self-signed certificates, this is expected).
You should see details about PHP 8.1.
(Optionally) You can now stop the PHP 7.4 container: ./bin/docker-compose stop php74