Welcome to the Linux Foundation Forum!

Lab 18.1. Make a Small Utility Available with Docker - Works but Needs a Bit More Instructions

arina01
arina01 Posts: 10
edited June 9 in LFS207 Class Forum

When following instructions in the container lab I get an error running the utility (both on my mac machine and on the Ubuntu VM I use for training

Static hostname: ubuntu-dev2
Operating System: Ubuntu 24.04 LTS

  • Install docker and log on into docker registry (Docker hub)
  • create directory (/opt/htpie in my case) with a file named Dockerfile not as per instructions. Reason: docker build is deprecated and I am not so savvy to use docker buildx build

ubuntu-dev2:/opt/httpie$ sudo cat /opt/httpie/Dockerfile
FROM alpine:edge
RUN apk add --no-cache httpie
CMD ["httpie"]

  • pull alpine:edge from the docker registry
  • compose image w new feature
    ubuntu-dev2:/opt/httpie$ sudo docker build -f httpie.Dockerfile -t httpie:latest

Try httpie to see if it works
ubuntu-dev2:/opt/httpie$ sudo docker run --rm httpie https httpie.io/hello
https: error: SSLError: HTTPSConnectionPool(host='httpie.io', port=443): Max retries exceeded with url: /hello (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)'))) while doing a POST request to URL: https://httpie.io/hello

This points to the fact that there are no CAs imported in the alpine vm on which I install httpie. Seeking what to do via a search engine
https://stackoverflow.com/questions/66201209/docker-build-using-ca-trust-bundle-from-host

Solution:
create a repositories file in the same directory where the Dockerfile exists (in my case /opt/httpie) and change the Dockerfile

ubuntu-dev2:/opt/httpie$ cat repositories
http://dl-cdn.alpinelinux.org/alpine/v3.13/main
http://dl-cdn.alpinelinux.org/alpine/v3.13/community

ubuntu-dev2:/opt/httpie$ cat httpie.Dockerfile
FROM alpine:edge
WORKDIR /etc/apk/
COPY repositories .

RUN apk add --no-cache httpie
CMD ["httpie"]

rebuild the image w the updated Dockerfile:
ubuntu-dev2:/opt/httpie$ sudo docker build -f httpie.Dockerfile -t httpie:latest

Build a container and query httpie

@ubuntu-dev2:/opt/httpie$ sudo docker run --rm httpie https httpie.io/hello
{"ahoy":["Hello, World! 👋 Thank you for trying out HTTPie 🥳","We hope this will become a friendship."],"links":{"homepage":"https://httpie.io","twitter":"https://twitter.com/httpie","discord":"https://httpie.io/discord","github":"https://github.com/httpie"}}

or see more info with
@ubuntu-dev2:/opt/httpie$ sudo docker run -it httpie https httpie.io/hello

The container seems to be destroyed once the utility runs. I got nothing running
ubuntu-dev2:/opt/httpie$ sudo docker ps

but I got several instances when running

ubuntu-dev2:/opt/httpie$ sudo docker ps -a
CONTAINER ID IMAGECOMMAND CREATED STATUS PORTS NAMES
22f08acc5db2 httpie "https https://www.h…" 3 minutes ago Exited (0) 3 minutes ago festive_jackson

Comments

  • luisviveropena
    luisviveropena Posts: 1,233

    Hi @arina01,

    I couldn't reproduce the issue. I had a different issue because when I copy and pasted the pdf content to the httpie.Dockerfile file, it did in a way that two lines were in just one, so I didn't work. When I fixed it, it worked.

    For another hand, Ubuntu 24.04 and the docker package kept "docker build". It also comes with buildx, the updated way to build images. So, the instructions worked for me:

    1.- cat httpie.Dockerfile
    FROM alpine:edge
    RUN apk add --no-cache httpie
    CMD ["httpie"]

    2.- luis@ubuntuserver:~$ docker build -f httpie.Dockerfile -t httpie:latest .
    [+] Building 25.3s (6/6) FINISHED docker:default
    => [internal] load build definition from httpie.Dockerfile 0.0s
    => => transferring dockerfile: 107B 0.0s
    => [internal] load metadata for docker.io/library/alpine:edge 0.6s
    => [internal] load .dockerignore 0.0s
    => => transferring context: 2B 0.0s
    => CACHED [1/2] FROM docker.io/library/alpine:edge@sha256:166710df254975d4a6c4c407c315951c22753dcaa829e020a3fd5d18fff70 0.0s
    => [2/2] RUN apk add --no-cache httpie 23.2s
    => exporting to image 1.2s
    => => exporting layers 1.2s
    => => writing image sha256:7edece15fc5f7684925f47fcc294ccb1e95a734fa2762fa85fb41026dc8efe7b 0.0s
    => => naming to docker.io/library/httpie:latest

    3.- luis@ubuntuserver:~$ docker run --rm httpie
    usage: httpie [-h] [--debug] [--traceback] [--version] {cli,plugins} ...
    httpie: error: Please specify one of these: 'cli', 'plugins'

    This command is only for managing HTTPie plugins.
    To send a request, please use the http/https commands:

    $ http POST pie.dev/post hello=world

    $ https POST pie.dev/post hello=world

    So, I say you can try the original example and take a look at the httpie.Dockerfile file format.

    Regards,
    Luis.

Categories

Upcoming Training