Skip to content
refresh-cw

GitHub Action

Docker Copy

v2.0.2 Latest version

Docker Copy

refresh-cw

Docker Copy

Run steps using docker

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Docker Copy

uses: tj-actions/[email protected]

Learn more about this action in tj-actions/docker-cp

Choose a version

CI Update release version. Public workflows that use this action.

docker-cp

GitHub action to run steps using docker

Examples

Copy from container to host

...
    steps:
      - uses: actions/checkout@v2

      - name: Set up QEMU
        uses: docker/[email protected]

      - name: Set up Docker Buildx
        uses: docker/[email protected]

      - name: Build
        uses: docker/build-push-action@v3
        with:
          context: .
          load: true
          push: false
          tags: user/app:latest

      - name: Run
        uses: tj-actions/docker-run@v2
        id: docker-run
        with:
          image: user/app:latest
          options: --name test-app -d
          args: sleep 10

      - name: Copy from container to host
        uses: tj-actions/docker-cp@v2
        with:
          container: ${{ steps.docker-run.outputs.container-id }}
          source: test.txt
          destination: test.txt
      
      - name: Display contents of test.txt
        run: cat test.txt
        # Hello World

Copy from host to container

...
    steps:
      - uses: actions/checkout@v2

      - name: Set up QEMU
        uses: docker/[email protected]

      - name: Set up Docker Buildx
        uses: docker/[email protected]

      - name: Build
        uses: docker/build-push-action@v3
        with:
          context: .
          load: true
          push: false
          tags: user/app:latest

      - name: Create test.txt
        run: echo "Hello World" >> test.txt

      - name: Run
        uses: tj-actions/docker-run@v2
        id: docker-run
        with:
          image: user/app:latest
          options: --name test-app -d
          args: sleep 10
      
      - name: Copy from host to container
        uses: tj-actions/docker-cp@v2
        with:
          container: ${{ steps.docker-run.outputs.container-id }}
          source: test.txt
          destination: test.txt
          local: false
      
      - name: Display contents of test.txt
        run: docker exec ${{ steps.docker-run.outputs.container-id }} cat test.txt

Inputs

INPUT TYPE REQUIRED DEFAULT DESCRIPTION
container string true Container name
destination string true Destination file or directory
local string false "true" Copy from container to local
(i.e container to host)
options string false Additional options passed to docker cp
source string true Source file or directory

If you feel generous and want to show some extra appreciation:

Buy me a coffee

Credits

This package was created with Cookiecutter using cookiecutter-action

Report Bugs

Report bugs at https://github.com/tj-actions/docker-cp/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your workflow that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.