docker run hello-world
docker --help
It's often installed on bash etc
for powershell try this
docker run -it ubuntu:latest
#-it=interactive pseudo terminal
then, in a different terminal
# shows the running containers
docker ps
finally attach on more shell
docker exec --it <CONTAINER ID OR NAME> /bin/bash
Making it easy for others to use your code
shipping code
FROM python:3.8-slim
RUN pip install emoji
WORKDIR /app
COPY hello-docker.py ./
RUN useradd -u 999 non-root-user
USER non-root-user
ENTRYPOINT ["python"]
CMD ["hello-docker.py"]
docker build . -t hello-docker:latest
COPY . .
These are used during build:) but be careful with what you pass in, args are stored in the image history
docker history hello-docker:latest
instead use buildx secrets if needed
Dockerfile
FROM alpine/git
RUN apk add --no-cache openssh-client
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
# Some private repo
RUN --mount=type=ssh git clone git@github.com:NIVANorge/STOP_import_GUI.git STOP
WORKDIR /git/STOP
CMD ["log"]
docker build --ssh default . -t secret-example
docker run secret-example
In most cases you can find images on dockerhub.
For internal niva images you need to follow instructions on google cloud artifactory setup and go to the artifactory.
docker run hello-docker
docker run -it hello-docker:latest :yarn:
docker run -it --entrypoint /bin/python hello-docker:latest
Config as ENV variables
docker run -e NIVA_ENV=1 hello-docker
docker run --env-file .env hello-docker
mount file
docker run -e FAVOURITE_PATH=/app/favorite.emojis \
--mount type=bind,source="$(pwd)"/favorite.emojis,target=/app/favorite.emojis,readonly \
hello-docker
docker-compose
-> docker compose
docker-compose has been rewritten to a Golang plugin for docker
zypper in docker-compose
version: '3.5'
services:
app:
build: .
entrypoint: shiny run --host 0.0.0.0 --port 6000 app.py
environment:
- SERVER=https://thredds.niva.no
- DATASET=msource-inlet.nc
ports:
- "5000:6000"
docker compose build
docker compose up
docker compose down --volumes
docker compose help
Still in the ./docker folder run
docker compose up
and go to
compose example