Skip to content

Instantly share code, notes, and snippets.

@ZiTAL
Last active January 12, 2024 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZiTAL/ab8573d5e03bafdf3bd57facba3cb407 to your computer and use it in GitHub Desktop.
Save ZiTAL/ab8573d5e03bafdf3bd57facba3cb407 to your computer and use it in GitHub Desktop.
podman: zerotik heroiera

podman

  1. add container sources to download from
echo "unqualified-search-registries = ['docker.io', 'ghrc.io', 'quay.io']" > .config/containers/registries.conf
  1. search container
podman search busybox
  1. download container
podman pull docker.io/library/busybox
  1. run container
podman run -it 9211bbaa0dbd
  1. show all running containers:
podman ps
  1. show all containers:
podman ps -a
  1. download nginx
podman pull docker.io/library/nginx
  1. run custom nginx
podman run --name pdm-nginx -p 8080:80 nginx

container name: --name pdm-nginx

-p 8080:80: map containers 80 port to localhost 8080 port

nginx: image name to build container

  1. inspect container
podman inspect pdm-nginx
  1. create a node script in a folder:
mkdir -p /home/projects/pdm-node
cd /home/projects/pdm-node
nano index.js
const http = require('http');

const server = http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/html' });
  res.end('Hello, podman');
});

const port = 8080;

server.listen(port, () => {
  console.log(`Server running at http://localhost:${port}/`);
});
  1. create Dockerfile
FROM node:18

WORKDIR /app

COPY index.js .

EXPOSE 8080

CMD ["node", "index.js"]
  1. build the custom image
podman build -t pdm-node .
  1. run custom image
podman run --name pdm-node -p 8080:8080 pdm-node:latest
  1. stop custom image
podman ps
podman CONTAINERID stop
  1. start custom image
podman start pdm-node
  1. register to docker hub: https://hub.docker.com

  2. login docker hub:

podman login docker.io
  1. build image to upload
podman build -t zital/pdm-node .
  1. show the new image in image listen
podman images
  1. publish image to docker.io
podman push zital/pdm-node
  1. check the image published online
https://hub.docker.com/r/zital/pdm-node
  1. search image in repository
podman search pdm-node
  1. pod help
podman pod --help
  1. podman create pod
podman pod create --name pdm-node-pod
  1. podman list pods:
podman pod ls
  1. list all containers including pods: there is a "pause" default container inside the empty pod
podman ps -a --pod
  1. add container to pod
podman run -dt --pod pdm-node-pod pdm-node
  1. check the container inside the pod
podman ps -a --pod
  1. stop container inside the pod
podman stop vibrant_goldwasser
  1. check it in the list
podman ps --pod
  1. start the container
podman start vibrant_goldwasser
  1. check it in the list
podman ps --pod
  1. remove container inside the pod
podman rm vibrant_goldwasser
  1. because of the container is running, we can remove it
podman stop vibrant_goldwasser
  1. remove container inside the pod
podman rm vibrant_goldwasser
  1. show all containers
podman ps -a --pod
  1. list pods
podman pod ls
  1. stop a pod
podman pod stop pdm-node-pod
  1. list pods
podman pod ls
  1. start pod
podman pod start pdm-node-pod
  1. stop pod
podman pod stop pdm-node-pod
  1. remove pod
podman pod rm pdm-node-pod
  1. create a pod
podman pod create --name pdm-node-pod
  1. add container to pod
podman run -dt --pod pdm-node-pod pdm-node
  1. check it
podman pod ls
  1. create kurbenetes YAML manifest config file
podman generate kube pdm-node-pod > pdm-node.yml
  1. delete pod
podman pod stop pdm-node-pod
podman pod rm pdm-node-pod
  1. create pod via kurbenetes config file
podman play kube pdm-node.yml
  1. list pods
podman ps --pod
  1. test url
curl localhost:8080
@ZiTAL
Copy link
Author

ZiTAL commented Jan 12, 2024

golang node-gatik aldatu dot

Iturria: https://www.youtube.com/watch?v=YXfA5O5Mr18

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