Difference between revisions of "Docker commands"

From Tech-Wiki
Jump to: navigation, search
(Created page with "Category:Linux After installing Docker, remember to configure the service to automatically start chkconfig docker on ; systemctl enable docker ; service docker start Ad...")
 
Line 16: Line 16:
  
 
docker-compose.yaml
 
docker-compose.yaml
version: '2'
+
version: '2'
services:
+
services:
 
   myproject:
 
   myproject:
 
     container_name: webserver
 
     container_name: webserver

Revision as of 15:16, 7 April 2020


After installing Docker, remember to configure the service to automatically start

chkconfig docker on ; systemctl enable docker ; service docker start

Add your docker user to the docker group:

usermod -a -G docker ec2-user

In order to create one container via CLI this command below will be the equivalent of the compose file further below.

docker create \
  --name=webserver --net=host -e VERSION=latest \
 -e PUID=$(id -u docker) -e PGID=$(id -g docker) \
 -v /var/www/html:/app:ro \
 --restart unless-stopped nginx
docker start nginx

docker-compose.yaml

version: '2'
services:
 myproject:
   container_name: webserver
   build: ./
   volumes:
     - /var/www/html:/app
   restart: always
   network_mode: host