Lab 18.1. Make a Small Utility Available with Docker - Works but Needs a Bit More Instructions
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
-
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:latest3.- 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.0
Categories
- All Categories
- 175 LFX Mentorship
- 175 LFX Mentorship: Linux Kernel
- 745 Linux Foundation IT Professional Programs
- 372 Cloud Engineer IT Professional Program
- 168 Advanced Cloud Engineer IT Professional Program
- 73 DevOps IT Professional Program - Discontinued
- 3 DevOps & GitOps IT Professional Program
- 98 Cloud Native Developer IT Professional Program
- 7.6K Training Courses & Learning Paths
- AI & ML Training
- Blockchain & Decentralized Identity Training
- Cloud & Containers Training
- Cybersecurity Training
- DevOps & Site-Reliability Training
- Linux Kernel Development Training
- Networking Training
- Open Source Best Practice Training
- System Administration Training
- System Engineering Training
- Web & Application Development Training
- 2 LFD103-JP クラス フォーラム
- 4 LFD210-CN Class Forum
- 764 LFD259 Class Forum
- 681 LFS101 Class Forum
- 2 LFS158-JP クラス フォーラム
- 162 LFS207 Class Forum
- 3 LFS207-DE-Klassenforum
- 4 LFS207-JP クラス フォーラム
- 61 LFS241 Class Forum
- 52 LFS242 Class Forum
- 42 LFS243 Class Forum
- 19 LFS244 Class Forum
- 4 LFS250-JP クラス フォーラム
- 166 LFS253 Class Forum
- 19 LFS256 Class Forum
- 1.4K LFS258 Class Forum
- 165 LFS261 Class Forum
- 26 LFS267 Class Forum
- 792 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 95 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 87 Storage
- 768 Linux Distributions
- 81 Debian
- 67 Fedora
- 22 Linux Mint
- 13 Mageia
- 24 openSUSE
- 150 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 465 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 98 Linux Security
- 78 Network Management
- 101 System Management
- 46 Web Management
- 106 Mobile Computing
- 18 Android
- 73 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 392 Off Topic
- 121 Introductions
- 181 Small Talk
- 29 Study Material
- 945 Programming and Development
- 310 Kernel Development
- 617 Software Development
- 977 Software
- 369 Applications
- 182 Command Line
- 5 Compiling/Installing
- 68 Games
- 317 Installation
- Archived
- 2 LFD140 Class Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)