Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Captcha Click on image to update the captcha .

Login

Register Now

Lorem ipsum dolor sit amet, consectetur adipiscing elit.Morbi adipiscing gravdio, sit amet suscipit risus ultrices eu.Fusce viverra neque at purus laoreet consequa.Vivamus vulputate posuere nisl quis consequat.

Docker basics Commands list

# Docker basics Commands list

## Docker installation

### Ubuntu

official _Ubuntu_ installation guide: https://docs.docker.com/install/linux/docker-ce/ubuntu/

#### uninstall older version, if applicable

sudo apt-get remove docker docker-engine docker.io containerd runc docker-ce docker-ce-cli containerd.io

#### installation from Docker respositories

#update package index
sudo apt-get update
# install packages to allow apt using https repositories
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
# add Dockers GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# configure the STABLE repository
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# ....and start the installation
sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io

Check the installation, by running a _hello world_ container:
sudo docker run hello-world

**Post-install steps to run _docker_ without prefixing it with _sudo_**


sudo groupadd docker
sudo usermod -aG docker $USER

If you used docker via _sudo docker_ before, you will run the following now:


sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
sudo chmod g+rwx "$HOME/.docker" -R

Check without _sudo_, by running a _hello world_ container:
docker run hello-world

### Windows###

For users with Windows 10 64-bit **Pro** or **Enterprise** or **Education**-version, use _Docker Desktop_ as shown here:
https://docs.docker.com/docker-for-windows/install/

Users with Windows 10 **Home**, Windows pre-10 versions, use _Docker Toolbox_ as shown here:
https://docs.docker.com/toolbox/toolbox_install_windows/
> Docker Toolbox ships also Oracle VirtualBox as virtualization solution, thereby this package is huge (~ 1GB) and
> should just be used if there are no other possibilities to run Docker.
> Windows 10 Home users should think about enabling the builtin Linux subsystem and install Ubuntu there !!

### Mac###

**Docker Desktop**: for Mac hardware >2010 and MacOS >= 10.13
https://docs.docker.com/docker-for-mac/install/

**Docker Toolbox**: for Mac users that do not cover above criteria
https://docs.docker.com/toolbox/toolbox_install_mac/

## Docker base commands##

# check version
docker version

# list images
sudo docker image ls
# delete an image
sudo docker image rm # where is shown in output of “sudo docker image ls

# list containers
sudo docker container ls [--all]
# delete a container
sudo docker container rm # where is shown in the output of “sudo container ls –all”

# run a container
sudo docker run
# run an ubuntu container, provide env variables and run command “env” within container to check for the variable provided
sudo docker run -e ENV_VAR1=myvalue1 ubuntu env | grep ENV_VAR

# run a plain nginx webserver,
# with random port assignment on local port => port 80 in container
# giving it a name “my-nginx”
# start the container in the background: “-d”
sudo docker run --name my-nginx -P -d nginx

# get details of a container
sudo docker inspect
sudo docker logs

# search for e.g. “nginx” containers from public repo
sudo docker search nginx

First container creation

cat > Dockerfile < Dockerfile <<EOF
FROM ubuntu:latest
RUN DEBIAN_FRONTEND=noninteractive apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -yq install net-tools nginx
EXPOSE 80
ENTRYPOINT ["/usr/sbin/nginx", "-g", "daemon off;"]
EOF

# build your image
sudo docker build -t / .

# test your container locally
sudo docker run / .

# push it to your Docker repository
sudo docker push /

Leave a reply

Captcha Click on image to update the captcha .

By commenting, you agree to the Terms of Service and Privacy Policy.