Skip to content

Instantly share code, notes, and snippets.

@rbo
Last active September 1, 2021 13:42
Show Gist options
  • Save rbo/be1e8402cfe2b896c3648ee78b8b74e9 to your computer and use it in GitHub Desktop.
Save rbo/be1e8402cfe2b896c3648ee78b8b74e9 to your computer and use it in GitHub Desktop.
Podman on Mac OS
$ export PATH=$(pwd):$PATH
$ podman-machine create box
Podman machine "box" already exists
$ podman-machine start box
Starting "box"...
(box) Check network to re-create if needed...
(box) Waiting for an IP...
Maximum number of retries (5) exceeded
$ podman-machine status
Running
$ podman-machine env --varlink
export PODMAN_VARLINK_BRIDGE="/usr/bin/ssh -F /dev/null -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none -o LogLevel=quiet -o PasswordAuthentication=no -o ServerAliveInterval=60 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@127.0.0.1 -o IdentitiesOnly=yes -i /Users/rbohne/.local/machine/machines/box/id_rsa -p 62106 varlink bridge"
export PODMAN_MACHINE_NAME="box"
# Run this command to configure your shell:
# eval $(podman-machine env --varlink)
$ eval $(podman-machine env --varlink)
$ podman ps
CONTAINER ID  IMAGE  COMMAND  CREATED  STATUS  PORTS  NAMES
$ podman images
REPOSITORY                            TAG      IMAGE ID       CREATED       SIZE
registry.access.redhat.com/ubi8/ubi   latest   cb642e6a9917   5 weeks ago   239 MB
$ podman run -ti registry.access.redhat.com/ubi8/ubi
Error: client must use upgraded connection to attach
$

With the help of: https://github.com/containers/libpod/blob/master/docs/tutorials/remote_client.md#remote-node-setup

eval $(podman-machine env)
ssh -t -L 127.0.0.1:1234:/run/podman/io.podman $PODMAN_USER@$PODMAN_HOST -p $PODMAN_PORT -i $PODMAN_IDENTITY_FILE -fN
export PODMAN_VARLINK_ADDRESS="tcp:127.0.0.1:1234"


$ podman run -ti registry.access.redhat.com/ubi8/ubi
[root@bdfd3f0f1e5f /]# exit

$ podman build -t runner .
STEP 1: FROM registry.access.redhat.com/ubi8/ubi-minimal
STEP 2: LABEL maintainer="Robert Bohne"
--> Using cache b80582b798dbcae4e65cfc2961d7e956b54817fa00cf9fc6b1bd001c1be14da8
STEP 3: ENV HOME='/runner/'
--> Using cache ef576176436d7e8f0ff16996e52b3afd997f90a185ecf5eb604d91105b48ff2c
STEP 4: RUN microdnf update -y && rm -rf /var/cache/yum
--> Using cache 726282214235e9fc0d7b789bfdccd1a7d816bb5c24f427ff7024336ea4f2ce9b
STEP 5: RUN microdnf install nss_wrapper gettext tar gzip -y     && microdnf clean all
--> Using cache dcd0342d4ea50a541386c8d909ff35314b46822e804ac4a7836d923b9e942a7e
STEP 6: RUN curl -L -s     https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux-4.2.9.tar.gz     | tar -C /usr/local/bin/ -zxv oc kubectl ;     chmod +x /usr/local/bin/oc ;     chmod +x /usr/local/bin/kubectl
--> Using cache 596675e06bf52c5ca021fc5840aa89048c74d412aacec586968cf75a079fe33b
STEP 7: RUN curl -L -#     --output /usr/local/bin/gitlab-runner     https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 ;     chmod +x /usr/local/bin/gitlab-runner
--> Using cache d4a97a8ba188fdb5f69ea3c2c5a97ed6966b058c903b77f74e17d3434490caef
STEP 8: RUN mkdir /container-scripts/ && cp /etc/passwd /container-scripts/ && chmod 666 /container-scripts/passwd
--> Using cache 104021750549809ae2af1cbd0235e73841b602f90f01267bc5fcc8131a187878
STEP 9: RUN mkdir -p /runner/.gitlab-runner/ && chmod -R 777 /runner
--> Using cache b0d1e9d6911bf0d3542ab40e7c87f03bd124d50108224b10f55030bedecbdf6d
STEP 10: ADD container-scripts/* /container-scripts/
--> Using cache 9201b43fdefad271542470b2519da2cd6d7e96cc7eaf0d35ec4c2a4506d60d5d
STEP 11: ENTRYPOINT ["/container-scripts/entrypoint.sh"]
--> Using cache 1dac2b7466666777d7cbd1a4eee0321367a65a019ca0c00c4fd514d896e372af
STEP 12: COMMIT runner
1dac2b7466666777d7cbd1a4eee0321367a65a019ca0c00c4fd514d896e372af

🤩🤘🏼

@xinredhat
Copy link

The podman is v1.x , right?

@rbo
Copy link
Author

rbo commented Oct 20, 2020

Right, didn't have time to test with Podman v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment