Create a Podman container
Install Podman
Podman is an easy and safe way for running containers. In Ubuntu or Debian it can be installed with:
sudo apt install podman
Create the container
podman run -d \
--name linux-cli --hostname linux-cli \
docker.io/dashohoxha/linux-cli:latest
podman ps
The command above is downloading a pre-made image from docker hub:
docker.io/dashohoxha/linux-cli:latest
If you want, you can build the image yourself (although it may take longer).
How to build your own image:
-
Download the
Dockerfile
, or copy/paste it from here:Dockerfile
FROM ubuntu:24.04
### install systemd
RUN apt update && \
apt upgrade --yes && \
apt install --yes systemd && \
systemctl set-default multi-user.target
CMD ["/sbin/init"]
RUN yes | unminimize
RUN DEBIAN_FRONTEND=noninteractive \
apt install --yes \
task-mate-desktop \
ubuntu-mate-core \
task-ssh-server
RUN apt install --yes \
mandoc less info plocate bash-completion \
wbritish highlight elinks ncal tree \
nano jed vim emacs netcat-openbsd ftp \
iputils-ping traceroute iputils-tracepath \
rsync aspell lynx highlight git tmux m4
### enable dark background for vim
RUN sed -i /etc/vim/vimrc -e 's/^"set background=dark/set background=dark/'
### set a better prompt for the root
RUN PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[01;33m\]@\[\033[01;36m\]\h \[\033[01;33m\]\w \[\033[01;35m\]\$ \[\033[00m\]' && \
echo "PS1='$PS1'" >> /root/.bashrc
### add user (user1, pass1) and improve its prompt
RUN useradd -m -s /bin/bash -G sudo user1 && \
echo user1:pass1 | chpasswd && \
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ \[\033[01;32m\]' && \
echo "PS1='$PS1'" >> /home/user1/.bashrc && \
x='"\033[00m"' && echo "trap 'echo -ne $x' DEBUG" >> /home/user1/.bashrc -
Build the image:
podman build --rm -t localhost/linux-cli:latest .
-
Create and start the container:
podman run -d \
--name linux-cli --hostname linux-cli \
localhost/linux-cli:latest
Using the container
-
To get a shell as
user1
inside the container, use this command:podman exec -it -u user1 -w /home/user1 linux-cli bash
-
For convenience, create an alias like this:
alias linux-cli='podman exec -it -u user1 -w /home/user1 linux-cli bash'
Now, whenever you type
linux-cli
you will get a shell inside the container.noteAppend this alias to
~/.bashrc
to make it persistent.
-
Inside the container, use
sudo su
to get root access. The default password ofuser1
ispass1
. -
If you need to recreate the container, you should remove the existing one first:
podman rm -fi linux-cli