i have yml file in github action in workflow in that file there is a docker image build and that push to docker hub.
Now we want to execute that image and run as a container in github action workflow of same yml file.
How to do it ?
Here is the yml file
name: vampi_docker
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: docker login
env:
# Docker_Hub_Username: xxxxxx
# Docker_Hub_Password: xxxxxx
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
repository: rashidmd/vampi_docker:latest
tags: latest, ${{ secrets.DOCKER_TOKEN }}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Build the Vampi Docker image
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
docker build . --file Dockerfile --tag rashidmd/vampi_docker:latest
# docker build . --file Dockerfile --tag vampi_docker:latest
- name: List images
run: docker images
- name: Docker Push
# run: docker tag vampi_docker:latest ${{secrets.DOCKER_USER}}/vampi_docker:latest
run: docker push rashidmd/vampi_docker:latest
After Docker push next command should have Docker container i.e., building docker container in it.
CodePudding user response:
You have already push image to remote, so in next step could just use run
to run a container with that image, it will fetch the image from dockerhub or private registry:
- name: Run a container
run: docker run --rm -it rashidmd/vampi_docker:latest