Python Test Automation Project with playwright-pytest using common dependencies
1.0K
Great point! Since Docker Compose V2 has replaced the old docker-compose command with docker compose, Iβve refined the documentation accordingly. Hereβs the final polished version with the latest syntax. ππ³
This repository contains a Playwright + Pytest test automation setup with common dependencies.
If you add a new dependency in requirements.txt or modify the code, you need to rebuild and push the updated Docker image to Docker Hub.
1οΈβ£ Build the new Docker image:
docker compose build
β What each flag does:
docker build β Builds a new Docker image.-t automationjutsu/playwright-pytest:latest β Tags (-t) the image with the name automationjutsu/playwright-pytest and the latest tag.. β The dot (.) specifies that the Dockerfile is located in the current directory.2οΈβ£ Verify that the image was created successfully:
docker images | grep automationjutsu/playwright-pytest
β Explanation:
docker images β Lists all Docker images on your machine.| grep automationjutsu/playwright-pytest β Filters the output to show only the relevant image.3οΈβ£ Log in to Docker Hub (if not already logged in):
docker login
β Explanation:
4οΈβ£ Push the updated image to Docker Hub:
docker push automationjutsu/playwright-pytest:latest
β Explanation:
docker push β Uploads the image to Docker Hub.automationjutsu/playwright-pytest:latest β Specifies the image name and tag to push.To test the updated Docker image and verify everything works fine:
docker compose run --rm -it automationjutsu/playwright-pytest:latest
β Explanation:
docker run β Starts a new container from the specified image.--rm β Automatically removes the container after it stops (useful for temporary runs).-it β Runs the container in interactive mode (-i keeps input open, -t allocates a terminal).automationjutsu/playwright-pytest:latest β The image name to use.docker compose to Run TestsIf youβre using Docker Compose, update and restart the container with:
docker compose build
docker compose up
β Explanation:
docker compose build β Rebuilds the Docker image based on the docker-compose.yml file.docker compose up β Starts the containers defined in docker-compose.yml.--force-recreate (optional) β Ensures the latest image is used, even if the container already exists:
docker compose up --force-recreate
To list all Docker images stored on your machine:
docker images
β Explanation:
docker images β Displays a list of locally stored Docker images.To remove old images and free up space:
docker rmi <image_id>
β Explanation:
docker rmi <image_id> β Removes an image from the local system.<image_id> with the actual IMAGE ID from docker images.If a container is running and needs to be stopped:
docker ps # List running containers
docker stop <container_id> # Stop a specific container
docker rm <container_id> # Remove a stopped container
β Explanation:
docker ps β Lists all running containers.docker stop <container_id> β Stops a container by its ID.docker rm <container_id> β Removes a stopped container from the system.| Action | Command | Description |
|---|---|---|
| Build image | docker build -t name:tag . | Builds a new Docker image from a Dockerfile. |
| List images | docker images | Shows all available images on the local machine. |
| Run container | docker run --rm -it name:tag | Runs a container interactively and removes it after exit. |
| Push image to Docker Hub | docker push name:tag | Uploads the image to Docker Hub. |
| Remove image | docker rmi image_id | Deletes a Docker image from the local system. |
| Stop a container | docker stop container_id | Stops a running container. |
| Remove a container | docker rm container_id | Deletes a stopped container. |
Build & start with docker compose | docker compose build && docker compose up | Rebuilds and runs containers defined in docker-compose.yml. |
π Done! Now you have a well-documented step-by-step guide inside Docker Hub with the latest Docker Compose commands, making it easy to update and push your Playwright Pytest Docker image. ππ³
Content type
Image
Digest
sha256:2b9d2d3beβ¦
Size
988.6 MB
Last updated
about 1 year ago
docker pull automationjutsu/playwright-pytest