I would install on a proxmox vm in your public vlan
First, apt install curl
Use this command:
curl -sSL https://get.docker.com/ | sh
Run as normal user:
sudo usermod -aG docker joe
Reboot, see if docker commands work as normal user.
Images and Containers
docker run hello-world
docker - indicates to os that we are using this program
run - creates and runs a docker container
hello-world - which image to put in container
Images and Containers
An image is an executable package that includes everything needed to run an application--the code, a runtime, libraries, environment variables, and configuration files.
A container is a runtime instance of an image--what the image becomes in memory when executed (that is, an image with state, or a user process).
When we ran the command, docker first checked to see if we had a hello-world software image, since we didn't, it found one on docker hub, downloaded it and ran it.
Container vs vm
A container runs natively on Linux and shares the kernel of the host machine with other containers. It runs a discrete process, taking no more memory than any other executable, making it lightweight.
By contrast, a virtual machine (VM) runs a full-blown “guest” operating system with virtual access to host resources through a hypervisor. In general, VMs provide an environment with more resources than most applications need.
Shows images that are installed or available locally to run
docker --help
What comands are available to me
Docker Examples
docker run debian echo "Hello world"
Docker has provisioned and launched our container, executed our echo command, and then shut down the container again. If you were to try to do something similar with a traditional VM, you would be waiting several seconds, possibly minutes.
Containers only run as long as their main process
Container isolation
-
Docker Examples
docker run -h CONTAINER -i -t debian /bin/bash
Gives container a hostname
docker ps
docker inspect gigantic_leavitt or whatever the name is
docker diff gigantic_leavitt #what changes have been made
docker logs gigantic_leavitt #cmd history
Docker Examples
docker ps -a or docker container ls -a
Shows all containers (including stopped ones)
docker rm gigantic_leavitt
docker commit #save changes to image
Docker image creation
Assume that you have done:
docker container run -ti ubuntu bash
then you apt update and install something, or create a file
now you want to save it.
docker container commit CONTAINER_ID
tag with docker image tag <IMAGE_ID> sometagname
Container isolation
-
Dockerfile
Dockerfile will define what goes on in the environment inside your container.
Map ports to outside world
Copy stuff into container
Portable to make sure container is same whenever it is run.
Dockerfile Example
# Use an official Python runtime as a parent image
FROM python:2.7-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt
# Make port 80 available to the world outside this container
EXPOSE 80
# Define environment variable
ENV NAME World
# Run app.py when the container launches
CMD ["python", "app.py"]