docker-compose up -d <name>; No such service: <name>

  • 问题描述

    使用docker-compose up -d docker-compose.yml运行启动一个docker,报错:

    ERROR: No such service: docker-compose.yml
    
  • 解决方案

    正常启动并不需要指定docker-compose.yml文件,直接docker-compose up -d 就行了。

    不过因此了解到docker-compose up -d 后面是可以跟参数的,跟的是service,就是docker-compose.yml里的一个服务,这样如果yml文件中有多个服务,docker-compose up -d <service>就可以只启动一个服务。

  • References

  1. docker-compose up -d ; No such service:
  2. 使用 docker compose 管理多个容器
Here is an example `docker-compose.yml` file to run Elasticsearch 8.6.2 and Kibana 8.6.2 using Docker Compose: ```yaml version: '3' services: elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:8.6.2 container_name: elasticsearch environment: - discovery.type=single-node ports: - "9200:9200" volumes: - esdata:/usr/share/elasticsearch/data kibana: image: docker.elastic.co/kibana/kibana:8.6.2 container_name: kibana ports: - "5601:5601" environment: - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 volumes: esdata: ``` In this example, we define two services: `elasticsearch` and `kibana`. The `elasticsearch` service uses the official Elasticsearch 8.6.2 Docker image, sets the `discovery.type` environment variable to `single-node` (to run a single Elasticsearch node), maps port 9200 to the host machine, and creates a volume named `esdata` to persist Elasticsearch data. The `kibana` service uses the official Kibana 8.6.2 Docker image, maps port 5601 to the host machine, and sets the `ELASTICSEARCH_HOSTS` environment variable to the hostname of the `elasticsearch` service (which is `http://elasticsearch:9200`). To run these services, navigate to the directory where the `docker-compose.yml` file is located and run the following command: ```bash docker-compose up -d ``` This will start both services in detached mode (in the background). To stop the services, run the following command: ```bash docker-compose down ``` Note that you may need to adjust the configuration options (such as ports and environment variables) to fit your specific use case.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值