Skip to content
Merged
Changes from all commits
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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