linux:software:docker

Docker

run
docker run -d --restart=always -p <host port>:<container port> -v <volume> --name <container name> <image name>:<optional version>
# run => pull and start in one command
# -d => detach on run
# --restart => always restart the container. Defaults to 'no'
# -p => publish port
# -v => volume list
# --name => assign a name to the container
pull + run
docker pull <image name>
docker pull pengbai/docker-supermario
docker run -d -p 8765:8080 --name mario pengbai/docker-supermario
volumes
# data in container is reset on container stop
 
# anonymus volume
docker run -d --restart=always -p <host port>:<container port> -v /app/data --name uptime-kuma louislam/uptime-kuma:1
 
# mount physical directory
docker run -d --restart=always -p <host port>:<container port> -v /home/mount/data:/app/data --name uptime-kuma louislam/uptime-kuma:1
 
# create a volume and mount it (perferred choice)
docker volume create uptime-kuma
docker run -d --restart=always -p <host port>:<container port> -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1
basic commands
# access container shell
docker exec -it 6f7d8322947c bash
 
# stop container and delete it
docker stop <container id>
docker rm <container id>
 
# delete local image
docker rmi <image id>
Dockerfile example
FROM ubuntu
MAINTAINER Tomislav Plečko, tomislav@plecko.hr
 
RUN apt update
RUN apt -y install libicu-dev libssl-dev
 
RUN mkdir /app
COPY Vacation /app
RUN chmod +x /app/dotnet
RUN cd /app
 
# ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
 
WORKDIR /app
 
CMD ["/app/dotnet","/app/NoticeVacation.dll","--vacation"]
 
#ENTRYPOINT /app/dotnet /app/NoticeVacation.dll --zulip
  • linux/software/docker.txt
  • Last modified: 2022/03/01 13:09
  • by 127.0.0.1