Skip to content

Conversation

@MikeMcC399
Copy link
Contributor

@MikeMcC399 MikeMcC399 commented Mar 4, 2025

Issue

The README > Run using Docker command example

docker run -v ${PWD}:/tmp:ro --rm -i ghcr.io/tcort/markdown-link-check:stable /tmp/README.md

uses PWD (Print Working Directory). The syntax ${PWD} can now be replaced by a simpler one using relative paths.

Relative paths

The Docker documentation for docker container run (with alias docker run) describes the option Mount volume (-v) using relative paths:

As of Docker Engine version 23, you can use relative paths on the host.

docker run -v ./content:/content -w /content -i -t ubuntu pwd

Change

Use the relative path . syntax instead of ${PWD}:

docker run -v .:/tmp:ro --rm -i ghcr.io/tcort/markdown-link-check:stable /tmp/README.md

Verification

For example, under Ubuntu 24.04.2 LTS

git clone https://github.com/tcort/markdown-link-check
cd markdown-link-check
docker run -v .:/tmp:ro --rm -i ghcr.io/tcort/markdown-link-check:stable /tmp/README.md

Confirm that markdown-link-check runs successfully.

Logs

$ docker run -v .:/tmp:ro --rm -i ghcr.io/tcort/markdown-link-check:stable /tmp/README.md
Unable to find image 'ghcr.io/tcort/markdown-link-check:stable' locally
stable: Pulling from tcort/markdown-link-check
43c4264eed91: Pull complete
453ca8c35a67: Pull complete
7a291b8a7b57: Pull complete
15929fe50b42: Pull complete
c70efbd48e66: Pull complete
4f4fb700ef54: Pull complete
0e06fe306355: Pull complete
b28c781acdb5: Pull complete
5e49cffc8ea6: Pull complete
68f40888b8a2: Pull complete
Digest: sha256:b812aa72676ed310c045d2c89d56abc1f88dd06e68edbea982799a7ff01c8569
Status: Downloaded newer image for ghcr.io/tcort/markdown-link-check:stable

FILE: /tmp/README.md
  [✓] https://www.npmjs.com/package/isemail
  [✓] https://github.com/gaurav-nelson/github-action-markdown-link-check
  [✓] https://pre-commit.com
  [✓] https://megalinter.io/latest/
  [✓] https://megalinter.io/latest/descriptors/markdown_markdown_link_check/
  [✓] https://www.npmjs.com/package/ms
  [✓] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement
  [✓] https://github.com/tcort/markdown-link-check/blob/master/LICENSE.md
  [✓] https://github.com/tcort/markdown-link-check/actions/workflows/ci.yml/badge.svg

  9 links checked.

@MikeMcC399 MikeMcC399 marked this pull request as ready for review March 4, 2025 10:14
@BaseMax
Copy link
Collaborator

BaseMax commented Mar 4, 2025

Dear Mike,

Thank you for your contribution. I see that your merge request is still in draft. Once it is ready for review, please let us know.

Many thanks.

@MikeMcC399

This comment was marked as resolved.

@BaseMax BaseMax requested review from WillGibson and smainil March 4, 2025 10:19
@MikeMcC399
Copy link
Contributor Author

Hopefully this minor improvement can be merged.

Using . instead of PWD tends to work better in a cross-platform environment including Windows with its different terminal window options.

@MikeMcC399
Copy link
Contributor Author

@BaseMax

This PR seems to have stalled. Is there any reason it can't be merged? How many approvals do you need before merging?

@BaseMax
Copy link
Collaborator

BaseMax commented Mar 31, 2025

Hi again. thank you so much.

Would you please explain a bit more? What is wrong with $PWD env var and why . and not $PWD?

https://www.docker.com/blog/best-way-learn-docker-free-play-docker-pwd/

https://stackoverflow.com/questions/43697810/meaning-of-pwd-path-to-directory

@MikeMcC399
Copy link
Contributor Author

Hi @BaseMax

The articles that you refer to are quite old:

https://www.docker.com/blog/best-way-learn-docker-free-play-docker-pwd/ (July 2017)

https://stackoverflow.com/questions/43697810/meaning-of-pwd-path-to-directory (April 2017)

In February 2023 Docker introduced the ability to use the relative path . instead of $PWD. See the current Docker documentation:

https://docs.docker.com/reference/cli/docker/container/run/#volume

$PWD doesn't work well on Windows, although it is no problem on Linux.

The relative path . works on all operating systems.

If you prefer not to pick up this suggestion, it's fine. You can close this PR. Users can just refer themselves to Docker documentation.

Unrelated to markdown-link-check, I switch a lot between Docker Desktop on Ubuntu and Docker Desktop on Windows with WSL2, so the recommendation is based on my experience. I have written a lot of the documentation for Cypress Docker images using this syntax and there has been no feedback that it is bad or doesn't work.

@MikeMcC399
Copy link
Contributor Author

I checked and in fact the relative path syntax . is only an advantage for Windows CMD terminal users. So that means it is only marginally better than the $PWD syntax. There is no difference on Ubuntu. Both work.

Windows terminals

Terminal $PWD .
Git Bash fails fails
CMD fails works
PowerShell works works

Ubuntu

Terminal $PWD .
Bash works works

@BaseMax
Copy link
Collaborator

BaseMax commented Apr 1, 2025

@smainil
@WillGibson

@MikeMcC399
Copy link
Contributor Author

@BaseMax

Thank you for the follow-up! I'm seeing 2 approvals now and no requests for change, so it looks like this could be merged.

@WillGibson
Copy link
Collaborator

I think we are deferring to @tcort because it's their project.

@BaseMax
Copy link
Collaborator

BaseMax commented Apr 7, 2025

Thank you for your contribution.

@BaseMax BaseMax merged commit e3236eb into tcort:master Apr 7, 2025
12 checks passed
@MikeMcC399
Copy link
Contributor Author

@BaseMax

Thank you for your contribution.

Thank you also for the team's work to maintain this repo!

@MikeMcC399 MikeMcC399 deleted the docs/docker-relative-bind branch April 7, 2025 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants