Linux

Install tmux with and Without Root Access

Install tmux with Root Access

sudo apt-get install tmux

*Tested on Ubuntu 18.04 LTS

Install tmux without Root Access

Download bash script from Sudhir Mitharwal 

wget https://gist.githubusercontent.com/sudkumar/6062def9d56d946b98b6a3853093ee74/raw/66f9bcc5d341e39233d763a7ecfe3402e9de0743/install_tmux_locally.sh

Execute the script and follow the instruction

chmod +x install_tmux_locally.sh
./install_tmux_locally.sh

*Tested on Ubuntu 16.04 LTS

tmux Quick Reference

Commands

Command Description
tmux Start a new tmux session
tmux ls List all running sessions
tmux attach -t 0 Connect to session named 0
tmux new -s database Create a new session named `database`
tmux rename-session -t 0 database Rename existing session from `0` to `database`

Command Keys

Keys Description
C-b % Split a pane into left and right
C-b " Split a pane into top and bottom
C-b <arrow key> Navigate to different pane
exit or Ctrl-d Close the pane
C-b c Create a new window
C-b p Go to the previous window
C-b n Go to the next window
C-b <number> Go to specific window number
C-b d Detach from the current session
C-b D Choose which session to detach
C-b z Toggle the pane fullscreen
C-b , Rename current window
C-b ? List available commands

*C-b means press and hold the Ctrl key and press b.

References

Shell Script Learning Resources

Debian Package Commands

Uninstalling Package

List installed packages

sudo apt list --installed

Remove package

sudo apt remove package_name
sudo apt remove package_name1 package_name2

Remove package with its configuration files

sudo apt purge package_name

Remove unused/orphaned packages

sudo apt autoremove
References

Install Podman, Buildah, and Skopeo on Ubuntu 18.04

Install podman and the gang

Execute the following commands to install podman, buildah, and skopeo from Kubic package repository.

. /etc/os-release
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | sudo apt-key add -
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install podman buildah skopeo

Install slirp4netns

In order to forward ports from container run by podman, you need to install slirp4netns by downloading the executable binary into a directory.

LATEST_VERSION=$(curl -s https://api.github.com/repos/rootless-containers/slirp4netns/releases/latest | jq -r '.tag_name')
curl -fL -o slirp4netns https://github.com/rootless-containers/slirp4netns/releases/download/${LATEST_VERSION}/slirp4netns-$(uname -m)
chmod +x slirp4netns

Add the directory into PATH variable by appending this line to shell init script (e.g. ~/.bashrc or ~/.zshrc) and restart the shell or source it.

export PATH=/path/to/binaries:$PATH

Test podman

Run a httpd container and forward port 8080 -> 18080

podman run -dt -p 18080:8080/tcp registry.fedoraproject.org/f29/httpd

If you see the error ERRO[0001] unable to write pod event: "write unixgram @00018->/run/systemd/journal/socket: sendmsg: no such file or directory", you seem to run podman in WSL2. Then you need to use the flag --events-backend=file to suppress this error:

podman run -dt -p 18080:8080/tcp --events-backend=file registry.fedoraproject.org/f29/httpd

Check the container status

podman ps

Podman will search in default registries if you don't specify full image name. The default registries are defined in /etc/containers/registries.conf. You can use command podman info to see the list of registries.

You should see the container's name and its status should be up like this:

CONTAINER ID  IMAGE                                 COMMAND               CREATED         STATUS            PORTS                    NAMES
6ffe71fff383  registry.fedoraproject.org/f29/httpd  /usr/bin/run-http...  44 seconds ago  Up 5 seconds ago  0.0.0.0:18080->8080/tcp  priceless_saha

Try to access the web page at http://localhost:18080 and you should see a HTML response.

curl http://localhost:18080

Dont' forget to stop and remove the container:

podman container stop priceless_saha
podman container rm priceless_saha

Test buildah

Buildah works the same as docker build, you just need to use podman build instead and everything works the same.

Clone the repository

git clone https://github.com/pacroy/flask-app.git

Build the image

buildah bud -t flask-app .

List all the image on local

buildah images
#OR
podman images

Run the image in a container

podman run -d -p 5000:5000 --events-backend=file flask-app

Check container status

podman ps

Try accessing applciation at http://localhost:5000/ 

Test skopeo

Use the following command to inspect an image properties on a remote repository:

skopeo inspect docker://registry.fedoraproject.org/fedora:latest

Use the following command to inspect an image configuration on a remote registry:

skopeo inspect --config docker://registry.fedoraproject.org/fedora:latest | jq

If you don't have jq installed, you can download it from https://stedolan.github.io/jq/.

You can also inspect your local images pulled by podman by using containers-storage transport.

skopeo inspect containers-storage:localhost/flask-app:latest

Copy an image from local registry to docker.io:

skopeo copy --dest-creds=$user:$password containers-storage:localhost/flask-app:latest docker://docker.io/pacroy/flask-app:latest

References