Skip to main content

Docker

Installationโ€‹

  • Followed instructions from Docker for Windows Installationโ†—๏ธ
  • Created Docker Hub account and downloaded from there
  • Ran Docker Desktop Installer.exe
  • Needed to restart PC and enable Hyper-V
  • To test if installation is good, run PowerShell and do docker --version

Docker Commandsโ€‹

  • To pull an existing image from Docker hub and run container: docker run hello-world
  • To list all images: docker image ls
  • To list running containers: docker container ls
  • To list all containers ever: docker container ls --all
  • docker run --interactive --tty ubuntu bash
  • docker run --detach --publish 80:80 --name webserver nginx
  • To stop running container: docker container stop <containername>
  • To remove container: docker container rm <containername>
  • To remove image by force: docker image rmi --force <imagename>
  • To build image: docker image build -t <username>/<imagename> .
  • To build container: docker container run <username>/<imagename>
  • To push Docker image to Docker Hub:
    docker login
    docker push <username>/<imagename>
  • To use volume: docker run -d -p <port_mapping> --name=<container_name> -v <directory_in_host>:<directory_in_container> <image>
  • To run and build docker-compose file: docker-compose up --build
  • To destroy: docker-compose down

accessing another docker containerโ€‹

reclaiming disk spaceโ€‹