Install docker on Ubuntu 18.10

Install docker:

# Uninstall old versions
sudo apt-get remove docker docker-engine containerd runc

# Install docker
sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common -y
curl -fsSL | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
   "deb [arch=amd64] \
   $(lsb_release -cs) \
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli docker-compose -y

# Config for run docker without sudo
sudo adduser $USER docker
sudo reboot now 
# or just logout for effect using command: pkill -u $USER
docker run hello-world


Ubuntu 18.10 called cosmic
Ubuntu 18.04 called bionic

Error from fetching

[arch=amd64] $(lsb_release -cs) stable

=> edit app source and change cosmic to bionic

sudo nano /etc/apt/sources.list

#update to: 
[arch=amd64] bionic stable

Docker useful command

# Login: create new account at
docker login

## List Docker CLI commands
docker container --help

## Display Docker version and info
docker --version
docker version
docker info

## Execute Docker image
docker run hello-world

## List Docker images
docker image ls

## List Docker containers (running, all, all in quiet mode)
docker container ls
docker container ls --all
docker container ls -aq

## To remove container, first get the name from “NAMES” column (docker container ls --all)
docker rm <container_name>

## To remove image, first get the image id from “IMAGE ID” column (docker image ls)
docker rmi <image_id>

## List all running containers
docker ps

## List all created containers (including stopped containers) (only IDs)
docker ps -aq
## Stop all running containers
docker stop $(docker ps -aq)

## View log of container
docker logs <container id>

## Attach ssh to running container
docker exec -i -t $CONTAINER_ID bash -l

## Connect to a running Docker container
docker attach $INSTANCE_NAME
where $INSTANCE_NAME get from: docker ps -a

## Start a stopped container
docker start $INSTANCE_NAME

## View details of a Docker container, including details of mounted folders
docker inspect $INSTANCE_NAME 

# View all data volume 
docker volume ls

# Delete Persistent Volumes
docker volume rm volumeid

Uninstall Docker

sudo service docker stop
sudo apt-get purge -y docker-engine docker docker-ce docker-ce-cli containerd runc
sudo apt-get autoremove -y --purge docker-engine docker docker-ce docker-ce-cli containerd runc
sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock

# Check docker process again
dpkg -l | grep -i docker

Leave a Reply

Your email address will not be published.Required fields are marked *