0
点赞
收藏
分享

微信扫一扫

DOCKER 进阶问题2

小暴龙要抱抱 2024-02-07 阅读 6

note 1: docker 利用  volume 进行 presist data。 eg : 

compose.yaml:

volumes:
  database: //# named db by self

list golbal volumes:

docker volume ls # the volumes on the disk

inpect someone volume:

docker volume inspect multi-container-app_database
# the name of volume (multi-container-app_database)  constitude by the container name(multi-container-app) + the db name (database),and separatored by "_"

result : docker volume inspect  multi-container-app_database

[
    {
        "CreatedAt": "2024-02-05T10:20:28Z",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "multi-container-app",
            "com.docker.compose.version": "2.24.3",
            "com.docker.compose.volume": "database"
        },
        "Mountpoint": "/var/lib/docker/volumes/multi-container-app_database/_data",
        "Name": "multi-container-app_database",
        "Options": null,
        "Scope": "local"
    }
]

 but you can‘t fint the folder ( docker/volumes/multi-container-app_database/_data ) on your host,

and this the explain by gpt :

note 2 : 

  view current containers process status 

docker-compose ps 
# warning : the code run must at the folder  include a yaml/yml file

run a container  :

docker-compose up -d 
# -d mean detach 。that's meaning for the  process run at backend and the command line can continue input 
docker run -d -p 8080:80 --name my_container my_image

note 3 :

explaination  $:docker build -t getting-started . 

note 4:

current  running  list containers ( if include stop status  containers)

docker ps  【-a】

 note 5:

# syntax=docker/dockerfile:1

FROM node:18-alpine  # Create a new build stage from a base image.
WORKDIR /app    
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
EXPOSE 3000

note 6:

$ docker run -dp 127.0.0.1:3000:3000 getting-started
举报

相关推荐

0 条评论