GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tcp-port opt to expose Docker API to a local TCP address by crazy-max · Pull Request #138 · docker/setup-docker-action

tcp-port opt to expose Docker API to a local TCP address #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
crazy-max merged 2 commits into docker:master from crazy-max:expose-tcp-input
Dec 16, 2024

Uh oh!

There was an error while loading. Please reload this page.

Merged

tcp-port opt to expose Docker API to a local TCP address #138

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
3a56725
tcp-port opt to expose Docker API to a local TCP address
crazy-max Dec 12, 2024
75153b5
chore: update generated content
crazy-max Dec 16, 2024
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

28 changes: 28 additions & 0 deletions 28 .github/workflows/ci.yml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,31 @@ jobs:
name: List contexts
run: |
docker context ls

tcp:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
#- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317
- macos-13
- windows-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker
id: setup_docker
uses: ./
with:
version: ${{ env.DOCKER_VERSION }}
tcp-port: 2378
-
name: Check docker info through TCP
run: |
docker info
env:
DOCKER_HOST: ${{ steps.setup_docker.outputs.tcp }}
8 changes: 5 additions & 3 deletions 8 README.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ The following inputs can be used as `step.with` keys
| `version` | String | `latest` | Docker CE version (e.g., `v24.0.6`). |
| `channel` | String | `stable` | Docker CE [channel](https://download.docker.com/linux/static/) (e.g, `stable`, `edge` or `test`). |
| `daemon-config` | String | | [Docker daemon JSON configuration](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file) |
| `tcp-port` | Number | | TCP port to expose the Docker API locally |
| `context` | String | `setup-docker-action` | Docker context name. |
| `set-host` | Bool | `false` | Set `DOCKER_HOST` environment variable to docker socket path. |
| `rootless` | Bool | `false` | Start daemon in rootless mode |
Expand All @@ -125,9 +126,10 @@ The following inputs can be used as `step.with` keys

The following outputs are available

| Name | Type | Description |
|--------|--------|--------------------|
| `sock` | String | Docker socket path |
| Name | Type | Description |
|--------|--------|---------------------------------------|
| `sock` | String | Docker socket path |
| `tcp` | String | Docker TCP address if tcp-port is set |

## Contributing

Expand Down
21 changes: 21 additions & 0 deletions 21 __tests__/context.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,27 @@ describe('getInputs', () => {
rootless: true,
} as context.Inputs
],
[
9,
new Map<string, string>([
['version', 'v24.0.8'],
['tcp-port', '2378'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
type: 'archive',
version: 'v24.0.8',
channel: 'stable'
},
context: '',
daemonConfig: '',
tcpPort: 2378,
rootless: false,
setHost: false
} as context.Inputs
],
])(
'[%d] given %p as inputs, returns %p',
async (num: number, inputs: Map<string, string>, expected: context.Inputs) => {
Expand Down
5 changes: 5 additions & 0 deletions 5 action.yml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ inputs:
daemon-config:
description: 'Docker daemon JSON configuration'
required: false
tcp-port:
description: 'TCP port to expose the Docker API locally'
required: false
context:
description: 'Docker context name. (default setup-docker-action)'
required: false
Expand All @@ -32,6 +35,8 @@ inputs:
outputs:
sock:
description: "Docker socket path"
tcp:
description: "Docker TCP address if tcp-port is set"

runs:
using: 'node20'
Expand Down
2 changes: 1 addition & 1 deletion 2 dist/index.js
Show comments
View file
Open in desktop

Large diffs are not rendered by default.

Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

2 changes: 1 addition & 1 deletion 2 dist/index.js.map
Show comments
View file
Open in desktop

Large diffs are not rendered by default.

Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

6 changes: 5 additions & 1 deletion 6 src/context.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import * as core from '@actions/core';
import {InstallSource} from '@docker/actions-toolkit/lib/docker/install';
import {parse} from 'csv-parse/sync';

import {InstallSource} from '@docker/actions-toolkit/lib/docker/install';
import {Util} from '@docker/actions-toolkit/lib/util';

export interface Inputs {
source: InstallSource;
daemonConfig?: string;
tcpPort?: number;
context: string;
setHost: boolean;
rootless: boolean;
Expand All @@ -21,6 +24,7 @@ export function getInputs(): Inputs {
return {
source: source,
daemonConfig: core.getInput('daemon-config'),
tcpPort: Util.getInputNumber('tcp-port'),
context: core.getInput('context'),
setHost: core.getBooleanInput('set-host'),
rootless: core.getBooleanInput('rootless')
Expand Down
14 changes: 13 additions & 1 deletion 14 src/main.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ actionsToolkit.run(
throw new Error(`'default' context cannot be used.`);
}

let tcpPort: number | undefined;
let tcpAddress: string | undefined;
if (input.tcpPort) {
tcpPort = input.tcpPort;
tcpAddress = `tcp://127.0.0.1:${tcpPort}`;
}

const install = new Install({
runDir: runDir,
source: input.source,
rootless: input.rootless,
contextName: input.context || 'setup-docker-action',
daemonConfig: input.daemonConfig
daemonConfig: input.daemonConfig,
localTCPPort: tcpPort
Comment thread
vvoland marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

});
let toolDir;
if (!(await Docker.isAvailable()) || input.source) {
Expand All @@ -38,6 +46,10 @@ actionsToolkit.run(
await core.group(`Setting outputs`, async () => {
core.info(`sock=${sockPath}`);
core.setOutput('sock', sockPath);
if (tcpAddress) {
core.info(`tcp=${tcpAddress}`);
core.setOutput('tcp', tcpAddress);
}
});

if (input.setHost) {
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.