howto:specific:learndocker
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| howto:specific:learndocker [2025/01/18 14:19] – More stuff alexdavis | howto:specific:learndocker [2025/01/22 16:51] (current) – [Workshop tasks] alexdavis | ||
|---|---|---|---|
| Line 48: | Line 48: | ||
| Containers are created from images. Containers are similar to virtual machines, but are not the same thing. They run applications in isolated, self-reliant environments. One of the advantages of Docker is that pretty much anywhere it runs, containers will run. | Containers are created from images. Containers are similar to virtual machines, but are not the same thing. They run applications in isolated, self-reliant environments. One of the advantages of Docker is that pretty much anywhere it runs, containers will run. | ||
| == Compose == | == Compose == | ||
| - | TODO | + | Docker Compose is an extra tool for managing the running of multiple-container applications. It makes things like networking easier, as well as configuration by storing parameters manually passed to //docker run// in a configuration file (normally called // |
| + | |||
| + | The // | ||
| + | < | ||
| + | version: " | ||
| + | services: | ||
| + | flask: | ||
| + | image: localhost/ | ||
| + | container_name: | ||
| + | ports: | ||
| + | - YourPort: | ||
| + | environment: | ||
| + | - DISPLAY_NAME=YourName | ||
| + | networks: | ||
| + | - external | ||
| + | |||
| + | # Below fixes a problem with Tardis container networking | ||
| + | networks: | ||
| + | external: | ||
| + | name: podman | ||
| + | external: true | ||
| + | </ | ||
| ==== Workshop tasks ==== | ==== Workshop tasks ==== | ||
| Line 67: | Line 88: | ||
| docker run -e DISPLAY_NAME=YourName --name flask -p YourPort: | docker run -e DISPLAY_NAME=YourName --name flask -p YourPort: | ||
| </ | </ | ||
| - | You can check if the container is working properly by making a request to the port it uses. | + | You can check if the container is working properly by making a request to the port it uses, by listing your running containers and by checking the logs of the container. |
| < | < | ||
| curl localhost: | curl localhost: | ||
| + | docker ps | ||
| + | docker logs flask | ||
| </ | </ | ||
| Then stop and remove the container. Note that docker does not automatically remove stopped containers, you can see stopped containers with //docker ps -a//. | Then stop and remove the container. Note that docker does not automatically remove stopped containers, you can see stopped containers with //docker ps -a//. | ||
| Line 75: | Line 98: | ||
| docker stop flask && docker rm flask | docker stop flask && docker rm flask | ||
| </ | </ | ||
| + | === Configure your container with Compose === | ||
| + | Make sure your current container is stopped, then edit the // | ||
| + | docker-compose up -d | ||
| + | The //-d// flag detaches the container output from your terminal window. Check the output from the container with //curl localhost: | ||
| + | < | ||
| + | Curl the port again - it should have changed. Stop your container again with // | ||
| + | === Extra tasks to look into === | ||
| + | * Look into mounting and accessing a volume with Compose | ||
| + | * Open a shell in the container with //docker exec -it flask(-compose) sh// | ||
| + | * Try finding a docker image online and adding it as a service | ||
| + | * Find a piece of self-hosted software you can run as a Docker container | ||
howto/specific/learndocker.1737209943.txt.gz · Last modified: 2025/01/18 14:19 by alexdavis
