Skip to main content

Docker Cheatsheet, Basic Docker commands

Docker Cheatsheet, List of Basic docker commands

$ docker run <containerId> #run docker container, first checks locally, if not found pull from remote repository
$ docker stop <containerId> #stop docker container
$ docker ps -a # list all the containers
$ docker rm <containerId> # delete docker container
$ docker rm $(docker ps -a -q -f status=exited) #deleted all the exited docker container
$ docker commit <container-id> <image-name>
$ docker search <imageName> #same as git repo
$ docker pull <imageName> #same as git pull

list network
$ docker network ls

create network
$docker network create <networkName>

inspect docker network
$ docker network inspect <networkName>

run container and attach to network
$docker run -it --net=<networkName> <containerName>

run multiple container in same network
$docker run -it --net=bridge <containerName>
$docker run -it --net=container:<containerName> <containerName>

create a docker file, first add maven docker plugin from https://github.com/spotify/dockerfile-maven in pom.xml
$mvn install dockerfile:build

run the above image as container
$ docker run -p <spring-boot-app-serverport>:<local-machine-port> -t <containername>

with command arguments
$ docker run -e "server.profile=dev" -p 8080:8080 -t <containerName>


To run docker without sudo first add docker as group in Ubuntu
$ sudo groupadd docker

Add user to this group
$ sudo gpasswd -a <username> docker

Restart docker
$ sudo service docker restart

Log out and Log in, now we can run the docker command without sudo

A curated list of Docker resources and projects
https://github.com/veggiemonk/awesome-docker

Comments

Popular posts from this blog

Spring Security with Spring Boot and MySQL

Spring Security with Spring Boot and MySQL In this tutorial I'll show how to use Spring Security with Spring Boot and MySQL. We'll implement a UserDetailsService provided by Spring Security. It is easy to configure Spring Security with Spring Boot and MySQL. You can also check how to run Spring Boot application inside docker container Steps: 1. Create a Spring Boot project from start.spring.io with following dependencies in your pom.xml file. You can choose gradle also for project dependencies. <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- dev tools for hot reloading --> <dependency> <groupId>org.springframework.b...

Live video streaming with ffmpeg and ffserver

Live video and audio streaming with ffmpeg and ffserver This is a guide on how to stream video using ffserver and ffmpeg in ubnutu. The ffmpeg ffserver version used is 3.3-1~16.04.york1. You can download ffserver from ffmpeg.org . I'm using linux mint 18. So, I've downloaded ffmpeg from the repository. You can follow the link below to install the latest version of ffmpeg. Install ffmpeg in linux mint 18 using command line . First, we need to setup our ffserver.conf to stream the audio and video properly. ffserver.conf file is usually located in /etc/ffserver.conf. You can either edit the ffserver.conf or create your own .conf file. I'll be creating my own .conf file named livestream.conf In console, type sudo nano /etc/livestream.conf Blank .ffm file will be created. Now, enter the required properties for streaming live video using ffserver #Default port HTTPPort 8090 HTTPBindAddress 0.0.0.0 MaxHTTPConnections 2000 MaxClients 1000 MaxBandwidth 100000 Custo...

How To install Docker in Linux Mint 18.2

How To install docker in Linux Mint 18.2 Codename: sonya Docker is a Container as a service (CaaS) platform which helps to eliminate "works in my computer" problems when working together with other members in the team. More here Docker for Linux Mint is availabe as a free Community Edition (CE). Installation is easy and straigh forward. We will install a stable release of docker. OS Requirements Linux Mint 18.2 (LTS) Architecture: x86_64 If you've the older version installed already, uninstall it $ sudo apt-get remove docker docker-engine docker.io Add repositories $ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - Since, Linux Mint 18.2 (sonya) is based on Ubuntu 16.04 (xenial), we've to use the release codename of Ubuntu 16.04 i.e. xenial. Also, we'll use the latest stable version $ sudo add-apt-repository "deb [arch=a...