小编Spa*_*roy的帖子

使用 dockerfile 操作 mkdir 命令

我无法在带有 dockerfile 的容器中使用 mkdir 命令创建目录。

我的 Dockerfile 文件很简单;

FROM php:fpm

WORKDIR /var/www/html

VOLUME ./code:/var/www/html

RUN mkdir -p /var/www/html/foo
Run Code Online (Sandbox Code Playgroud)

通过这种方式我创建了一个简单的 php: fpm 容器。我写信创建一个名为 foo 的目录。

docker build -t phpx .
Run Code Online (Sandbox Code Playgroud)

我已经用上面的代码构建了。

在我的 docker-compose 文件中,如下所示。

version: '3'

services:
web:
container_name: phpx
build : .
ports:
- "80:80"
volumes:
- ./code:/var/www/html
Run Code Online (Sandbox Code Playgroud)

之后; 运行以下代码,我进入了容器内核。

docker exec -it phpx /bin/bash
Run Code Online (Sandbox Code Playgroud)

但是/var/www/html中没有一个叫foo的目录。

我想知道我哪里做错了。你能帮助我吗?

docker dockerfile docker-compose

20
推荐指数
2
解决办法
5万
查看次数

如何在node.js中要求一个类

我的代码有效..

var express=require("express"),
app=express();

class bar {
   constructor()
   {
     this.user_name=null;
     this.user_surname=null;
     this.user_age=null;
   }

   name(user_name) {
     this.user_name=user_name;
     return this;
   }

   surname(user_surname) {
     this.user_surname=user_surname;
     return this;
   }

   age(user_age) {
     this.user_age=user_age;
     return this;
   }

   get(callback) {

     var list ={};

     list.uname=this.user_name;
     list.usurname=this.user_surname;
     list.uage=this.user_age;

     callback(list);
   }

}



app.get("/liste/:ext",function(req,res){

  var ext=req.params.ext;

  res.setHeader('Content-Type', 'application/json');

  if(ext==1)
  {
    var newbar=new bar();
    newbar.name("alex").surname("broox").age(32).get(function(result){
      res.json({data:result})
    })

  }

  if(ext==2)
  {
    var newbar=new bar();
    newbar.name("alex2").get(function(result){
      res.json({data:result})
    })
  }

})

app.listen(4000,function(log){
  console.log("listening")
})
Run Code Online (Sandbox Code Playgroud)

但..以下代码不起作用..要求来自其他文件的类..

test.js

module.exports = {

class bar {
   constructor()
   {
     this.user_name=null; …
Run Code Online (Sandbox Code Playgroud)

node.js

3
推荐指数
2
解决办法
1万
查看次数

标签 统计

docker ×1

docker-compose ×1

dockerfile ×1

node.js ×1