If using ubuntu and apt-get:
sudo apt update
sudo apt install docker.io
For Fedora or CentOS, change apt
to yum
or dnf
, depending on which one you use.
https://docs.docker.com/engine/install/linux-postinstall/
docker run -it ubuntu:latest
docker run -v /home/tsantini/my_folder_at_host:/mnt/myfolder -it name_of_container:latest
docker build -t name_of_the_conteiner folder_with_Docker_file
FROM ubuntu:latest
RUN apt update && \
DEBIAN_FRONTEND=noninteractive \
apt install -y --no-install-recommends \
vim \
git \
g++ \
gcc \
tmux \
ca-certificates \
make \
cmake-curses-gui \
file \
dc \
libpthread-stubs0-dev \
parallel
After building and testing your container, you might be interested in communicating your container with the host to share files. Please type the following:
docker run -v /home/tsantini/my_folder:/mnt/myfolder -it container_name:latest
This container has several MRI image processing packages.
docker run -v local_folder:mounting_folder --rm -it tsantini/image_processing
To test, you can run:
mrconvert --help
More information about this conteiner at https://hub.docker.com/r/tsantini/image_processing
You can request access to the Dockerfile for this conteiner.
-it
interactive mode: open the container as a terminal
-v host_location:docker_mount_location
mount a local folder into the docker, for example: -v /home/tsantini/my_folder:/mnt/myfolder
--rm
remove the content of the conteiner after exiting. It's usually the default.
Add the following argument to docker run
:
-u $(id -u ${USER}):$(id -g ${USER})
- Login to docker hub
docker login --username=your_user_name
- check the image you want to push
docker images
- tag this image
docker tag image_ID your_user_name/image_name:new_tag
- push the container
docker push your_user_name/image_name
- check the images
docker images
- retag
docker tag images_ID your_user_name/image_name:new_tag
docker rmi image_name:flag
docker save [OPTIONS] IMAGE [IMAGE...]
-> saves the conteiner in a tar file, for example docker your_user_name/image_name > ~/conteiner.tar
docker load [OPTIONS]
-> loads the conteiner from a tar file, for example docker load < ~/conteiner.tar
example:
singularity pull camino.sif docker://tsantini/camino:latest
example how to run singularity sif container:
singularity exec -B $PWD:$PWD -W $PWD ./container.sif commands_inside_container
docker ps
-> check the running conteiners
docker stats
-> shows the CPU/memory/IO usage of the conteiners
docker ps
-> check the running conteiners
docker commit container_ID your_user_name/image_name:tag
-> commit the container
docker push your_user_name/image_name:tag
-> push to dockerhub
- enable anyone in docker group to run dockerd without password
- in the wsl2 terminal, type
sudo visudo
- add this lines to the file:
%docker ALL=(ALL:ALL) NOPASSWD: /usr/bin/dockerd
- write a script to check if the dockerd is already runing, if not, start it
#!/usr/bin/bash
if ! docker info > /dev/null 2>&1; then
echo "This script uses docker, starting it now"
sudo dockerd > ~/dockerd.txt 2>~/dockerd_err.txt &
fi
-
add the script to your .bashrc, example:
/home/username/start_docker.sh
-
go to your
.docker\config.json
and remove the line that starts withcredsStore
, you will be able to login in your dockerhub after that
Delete some images:
docker rmi id:tag
docker image prune -f
Delete all containers using the following command:
docker rm -f $(docker ps -a -q)
Delete all volumes using the following command:
docker volume rm $(docker volume ls -q)
Clean up unused stuff:
docker container prune -f
docker image prune -f
docker volume prune -f