-
Notifications
You must be signed in to change notification settings - Fork 53
Description
There are some documentation how to get Docker up and running in docker-compose.yml file. But here is a summary what steps have we done to make Docker work.
Maybe using Docker should be documented better at Seravo docs.
Bring latest updates from Seravo stack
If you have older project, first step is the get all the updates from Seravo stack to your project.
Create .env file
- Create
.envfile in the root of the project. - Add line
SITE=[project_name]to the.envfile. - Remember to change
[project_name]for real project name which should match name inconfig.ymlfile. - By default
[project_name]iswordpress.
Add port bindings
Add port bindings in docker-compose.yml file:
Currently:
ports:
- 80
- 443
- 22Added port bindings:
ports:
- 80:80
- 443:443
- 22:22Update hosts file
Local URL for the project needs to be added manually in the /etc/hosts file by adding line:
127.0.0.1 [project_name].localOnce again remember to change [project_name] for the real project name.
Start Docker
Start Docker by running docker-compose up.
If everything worked you should be able to access [project_name].local URL in the browser.
Clean up
Sometimes clean up is needed, it can be done with these commands:
docker-compose down -v --remove-orphans
rm -rf .vagrantHow to access Docker container
Accessing Docker container is needed for running WP CLI commands for example.
docker-compose exec --user vagrant wordpress bash--user vagrant is needed in order to have privileges to run commands like wp-pull-production-db.
If above does not work, try accessing using container ID.
- Get container ID:
docker ps. - Access:
docker exec -it --user vagrant {ID} sh - Or using bash:
docker exec -it --user vagrant {ID} bash
Remember to change {ID} for the actual ID.
Summary
There are extra manual steps to take when using Docker. Maybe in the long run some of these can be automated. Like adding port bindings by default?
Anyways we wanted to share our findings and how we have started using Docker.
We have at least tested with macOS Big Sur and WIN 10 with WSL2 system.
cc: @elguitar