I have a Dockerfile that creates a file.
Dockerfile
FROM --platform=linux/amd64 amazonlinux:2 AS base
RUN mkdir /output && touch /output/hello.txt
FROM scratch AS export
COPY --from=base /output/hello.txt /
if I build the Dockerfile locally with
docker build -f Dockerfile --output . .
I have my hello.txt
file in my folder as expected. But if I do the same through Github Actions as
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Run
run: |
docker build -f Dockerfile --output . .
- name: Check
run: |
ls -la
the file is not in the folder. Do you know how can I retrieve the Dockerfile output through github actions?
The custom build output functionality you are using is available with the Buildkit backend. To use the Buildkit backend over the classic backend you either can:
DOCKER_BUILDKIT=1
when running the docker command"features": { "buildkit": true }
to the root of the config json.docker buildx
as you are attemptingDocker buildx is being set up in the Github Actions so just have to replace docker build
with docker buildx build
.
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Run Buildx
run: |
docker buildx build -f Dockerfile --output . .
- name: Check
run: |
ls -la