没有这样的文件或目录:Docker组成

时间:2019-04-07 21:14:35

标签: docker docker-compose dockerfile

我用docker-compose将我卑鄙的应用程序进行了docker化。这很好。 现在,我尝试使用“音量”,以便在编码时我的角度应用程序(带有ng服务)和我的快速应用程序(带有nodemon.js)自动重新启动。 但是对于有角容器和特快容器,都出现相同的错误:

@objc func switchStateDidChange(_ sender: UISwitch) {
     if exportDataSwitch.isOn {
        sections.remove(at: 1)
        tableView.deleteSections([1], with: .fade)
     } else {
        sections.insert(“title”, at: 1)
        tableView.insertSections([1], with: .fade)
        }
    }

override func numberOfSections(in tableView: UITableView) -> Int {
    return sections.count
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if(section == 0) {
        return 1
    } else if(section == 1) {
        return 1
    } else if(section == 2) {
        return 2
    } else {
        return 0
    }
}

查看我的文件夹层次结构:

angular_1   |
angular_1   | up to date in 1.587s
angular_1   | found 0 vulnerabilities
angular_1   |
angular_1   | npm ERR! path /usr/src/app/package.json
angular_1   | npm ERR! code ENOENT
angular_1   | npm ERR! errno -2
angular_1   | npm ERR! syscall open
angular_1   | npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'
angular_1   | npm ERR! enoent This is related to npm not being able to find a file.
angular_1   | npm ERR! enoent
angular_1   |
angular_1   | npm ERR! A complete log of this run can be found in:
angular_1   | npm ERR!     /root/.npm/_logs/2019-04-07T20_51_38_933Z-debug.log
harmonie_angular_1 exited with code 254

这是我的Angular Dockerfile:

-project
  -client
    -Dockerfile
    -package.json
  -server
    -Dockerfile
    -package.json
  -docker-compose.yml

我的Express Dockerfile:

# Create image based on the official Node 10 image from dockerhub
FROM node:10

# Create a directory where our app will be placed
RUN mkdir -p /usr/src/app

# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app

# Copy dependency definitions
COPY package*.json /usr/src/app/

# Install dependecies
RUN npm install

# Get all the code needed to run the app
COPY . /usr/src/app/

# Expose the port the app runs in
EXPOSE 4200

# Serve the app
CMD ["npm", "start"]

最后是我的docker-compose.yml

# Create image based on the official Node 6 image from the dockerhub
FROM node:6

# Create a directory where our app will be placed
RUN mkdir -p /usr/src/app

# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app

# Copy dependency definitions
COPY package*.json /usr/src/app/

# Install dependecies
RUN npm install

# Get all the code needed to run the app
COPY . /usr/src/app/

# Expose the port the app runs in
EXPOSE 3000

# Serve the app
CMD ["npm", "start"]

2 个答案:

答案 0 :(得分:1)

我也有这个错误,原来是我的docker-compose版本存在问题。我在Windows 10上运行WSL,并且WSL中安装的docker-compose版本无法正确处理卷绑定。我通过删除/usr/local/bin/docker-compose然后将别名添加到Windows docker-compose可执行文件alias docker-compose="/mnt/c/Program\ Files/Docker/Docker/resources/bin/docker-compose.exe"

来解决此问题。

如果上述内容不适用于您,请尝试update your version of docker-compose

答案 1 :(得分:0)

您的交易量部分应如下所示:

    volumes:
      - .:/usr/app
      - /usr/app/node_modules

在Docker容器中挂载源文件夹node_modules之后被“覆盖”,因此您需要添加“ / usr / app / node_modules”。使用适当的docker-compose.yml-https://all4developer.blogspot.com/2019/01/docker-and-nodemodules.html

的完整教程