-2

how can we use below sample code in Docker-file

sample 1 docker container run -p 80:4000 -v $(pwd):/site/jekyll-serve sample 2 docker container run -p 8080:80 --name web2 -v $(pwd):/usr/share/nginx/html nginx

i have recently started learning docker and swarm orchestration just need to know about this issue. is there any update in future release or any fixes to this....???

1 Answers1

0

as of 9/9/21 you need to use docker compose

https://docs.docker.com/compose/networking/

services:
  web:
    build: .
    ports:
      - "80:4000"

https://docs.docker.com/storage/volumes/

services:
  frontend:
    volumes:
      -  $(pwd):/site/jekyll-serve
volumes:
  myapp:

Named volumes: Docker-compose named mounted volume

my-named-volume:
     driver_opts:
           type: none
           device: /home/full/path #NOTE needs full path (~ doesn't work)
           o: bind
Schalton
  • 2,867
  • 2
  • 32
  • 44
  • ok thanks...!!! can you share me how to add named volumes named volumes..for this.. – Kishan Panchal Sep 09 '21 at 06:29
  • Someone else has already answered that throughly here: https://stackoverflow.com/questions/35841241/docker-compose-named-mounted-volume – Schalton Sep 09 '21 at 07:38
  • you need $(pwd) when calling docker directly. But compose supports relative paths. `./:/site/jekyll-serve` is sufficient. – Chris Becke Sep 09 '21 at 10:20