Installing Docker on Ubuntu VM via Guacamole

Accessing the VM via Guacamole:

  • Use Ctrl+Alt+Shift to enable copy-paste in Guacamole.

Docker Installation:

  1. Follow the [official documentation](https://docs.docker.com/engine/install/ubuntu/) to install Docker on Ubuntu using the repository.
  2. Run the following commands:
    sudo apt update
    sudo apt install docker-ce docker-ce-cli containerd.io
  • Or use the one-liner installation (less secure):
    curl -sSL https://get.docker.com | sudo sh

Installation Verification:

  • Run 'sudo docker run hello-world' to verify the installation.

Additional Configuration

  • Add your user to the Docker group to run Docker without sudo.
    sudo usermod -aG docker <user>
    sudo reboot  # Restart the VM to apply the changes.
  • Add Docker and Docker Compose autocompletion to bash:
    sudo apt update
    sudo apt install bash-completion curl
    sudo mkdir /etc/bash_completion.d/
    sudo curl -L https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /etc/bash_completion.d/docker.sh
    sudo curl -L https://raw.githubusercontent.com/docker/compose/1.24.1/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose

Installation Verification

- Basic Commands:

docker info  # Displays information about the Docker engine.
docker ps    # Displays running containers.
docker ps -a # Displays all containers.
  • Container Manipulation:
  • Start a Debian container in attached mode: `docker run debian`
  • For container manipulation, refer to useful commands [here](https://devhints.io/docker).

Searching on Docker Hub

- Download and run an Nginx container:

docker pull nginx
docker run --name "test_nginx" nginx

- To access Nginx, configure the port correctly:

docker stop test_nginx
docker rm test_nginx
docker run -p 8080:80 --name "test_nginx" nginx

Using Other Containers

- Launch a Funkwhale container:

docker run --name funky_container -p 80:80 funkwhale/all-in-one:1.0.1
docker rm -f funky_container  # Remove the container after use.

Optional: Wordpress, MYSQL, and Environment Variables

- Create a network for Wordpress:

docker network create wordpress

- Download and run a MySQL container:

docker run --name mysql_container -e MYSQL_ROOT_PASSWORD=<password> -e MYSQL_DATABASE=<dbname> -e MYSQL_USER=<dbuser> -e MYSQL_PASSWORD=<dbpassword> -d mysql:5.7

- Download and run a Wordpress container:

docker run --name wordpress_container -p 8080:80 --network wordpress -e WORDPRESS_DB_HOST=mysql_container -e WORDPRESS_DB_USER=<dbuser> -e WORDPRESS_DB_PASSWORD=<dbpassword> -e WORDPRESS_DB_NAME=<dbname> -d wordpress

Cleanup

- Remove stopped containers:

docker rm $(docker ps -aq -f status=exited)

- Remove an image:

docker rmi <image_id>

Advanced Exploration

- Decompose a Docker container:

docker export <container_name> -o container.tar
tar -C container_decompressed -xvf container.tar
Portainer

- Launch a Portainer instance:

docker volume create portainer_data
docker run --detach --name portainer -p 9000:9000 -v portainer_data:/data -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer-ce
  • Access the Portainer interface via [http://localhost:9000].
  • Create an admin account and explore the Portainer interface.
  • Use Portainer to create containers and manage your Docker installation.
teaching_assistant/workflow/docker_installation_and_experimentation.txt · Last modified: 2024/05/15 10:06 by Ralph
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0