I'm struggling to debug my Dockerfile in GitHub Codespaces. I need to pull error logs when the Dockerfile runs from the devcontainer, but I can't figure out why it's failing. My goal is to download and install the gotty package into `/usr/local/bin`. Here's my Dockerfile:
FROM mcr.microsoft.com/devcontainers/java
# Get gotty for terminal output to webpage
RUN apt-get update &&
apt-get install -y curl &&
curl -fL https://github.com/yudai/gotty/releases/download/v1.0.1/gotty_linux_amd64.tar.gz | tar -xz -C /usr/local/bin
After rebuilding the container, there are no error messages, but gotty doesn't show up in `/usr/local/bin`, and the compressed file isn't downloaded either. Anyone able to spot issues or suggest fixes? The entire repo can be found [here](https://github.com/dencee/nahom-shell-game).
1 Answer
It looks like you’ve added your Dockerfile, but you need to make sure that your devcontainer is set up to use it. In `devcontainer.json`, you're currently using a pre-defined image instead of your custom Dockerfile, which is why you're not seeing any logs to troubleshoot. Check out this guide on how to properly set up your Dockerfile: [Dockerfile Guide](https://containers.dev/guide/dockerfile). You might need to specify the path of the Dockerfile relative to your `devcontainer.json` if it's located in a different directory!
Exactly! You just need to specify that path correctly, and you can build on top of the existing java image. Good luck!
Got it! So if I set the image key in `devcontainer.json` to "dockerfile": "../Dockerfile", will that let me inherit the java image and add my customizations? Just want to make sure before I try it out.