|
@@ -0,0 +1,72 @@
|
|
|
+---
|
|
|
+title: Docker & Container
|
|
|
+categories: [cheatsheets]
|
|
|
+tags: [workflow, docker, podman, container]
|
|
|
+---
|
|
|
+
|
|
|
+# Docker & Container
|
|
|
+
|
|
|
+## Installation
|
|
|
+
|
|
|
+```sh
|
|
|
+sudo pacman -Sy podman cockpit-podman
|
|
|
+```
|
|
|
+
|
|
|
+## Using Dockerfiles
|
|
|
+
|
|
|
+* Build a custom docker image using a dockerfile
|
|
|
+
|
|
|
+```sh
|
|
|
+podman build -f Dockerfile --tag <customtag>
|
|
|
+```
|
|
|
+
|
|
|
+* Running the container
|
|
|
+
|
|
|
+```sh
|
|
|
+podman run <arguments> <customtag>
|
|
|
+```
|
|
|
+
|
|
|
+### Arguments
|
|
|
+
|
|
|
+```sh
|
|
|
+# remove after usaging the container
|
|
|
+--rm
|
|
|
+
|
|
|
+# mount the current path to `/share` in the container
|
|
|
+-v `pwd`:/share
|
|
|
+
|
|
|
+# Portforwarding the port `8080` (container) to `8000` (local)
|
|
|
+-p 8000:8080
|
|
|
+
|
|
|
+# Keep stdin open
|
|
|
+-i
|
|
|
+
|
|
|
+# Allocate pseudo tty
|
|
|
+-t
|
|
|
+```
|
|
|
+
|
|
|
+
|
|
|
+## Usecases
|
|
|
+
|
|
|
+* Directly dropping into a container shell:
|
|
|
+
|
|
|
+```
|
|
|
+sudo podman run --rm -it --entrypoint=bash tomcat:6
|
|
|
+```
|
|
|
+
|
|
|
+
|
|
|
+## Usefull Aliases
|
|
|
+
|
|
|
+```
|
|
|
+# dropping into a shell
|
|
|
+alias podshell="sudo podman run --rm -it --entrypoint=bash"
|
|
|
+
|
|
|
+# sharing files via http(s) with self-signed certificate
|
|
|
+alias nginxhere="sudo podman run --rm -ti -p 80:80 -p 443:443 -v `pwd`:/srv/data swrzm/nginx"
|
|
|
+
|
|
|
+# Opening a SMB server in the same dir
|
|
|
+smbhere() {
|
|
|
+ local sharename
|
|
|
+ [[ -z $1 ]] && sharename="SHARE" || sharename=$1
|
|
|
+ sudo podman run --rm -it -p 445:445 -v "${PWD}:/tmp/serve" swrzm/impacket smbserver.py -smb2support $sharename /tmp/serve
|
|
|
+```
|