Skip to content

doc(readme): Add docker usage doc #3103

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.

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
merged 2 commits into from
May 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ Download the latest releases from the [GitHub release page](https://github.com/j

Pull the [jq image](https://github.com/jqlang/jq/pkgs/container/jq) to start quickly with Docker.


### Run with Docker
##### Example: Extracting the version from a `package.json` file
```bash
docker run --rm -i ghcr.io/jqlang/jq:latest < package.json '.version'
```
##### Example: Extracting the version from a `package.json` file with a mounted volume
```bash
docker run --rm -i -v "${PWD}":/pwd -w /pwd ghcr.io/jqlang/jq:latest '.version' package.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One possible improvement could be to do -v "$PWD:$PWD" -w "$PWD" to make paths work more as expected

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand, Can you maybe share an example command that will act in an unexpected way?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one would happen to use absolute host paths in arguments etc they won't work, ex:

docker run --rm -i -v "${PWD}":/pwd -w /pwd ghcr.io/jqlang/jq:latest -f $PWD/file.jq ...

but even with the -v -w trick above paths outside host $PWD will not work... so not perfect either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a slight difference no need to fix. -f accepts relative path, env.PWD is different, but should be ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened a PR #3105

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@itchyny yeap not big thing but it has hit me a couple of times before :)

```

### Building from source

#### Dependencies
Expand Down