[英]How to run a Docker image inside your EC2 container?
我有一个EC2实例,里面有以下docker镜像:
REPOSITORY TAG IMAGE ID
grant/docker-app hookedup b99f4ad
在我的本地机器上,我一直在使用docker-compose build
和docker-compose up
来运行服务器。
如何在EC2实例上运行映像?
我使用Amazon Linux AMI登录AWS。 我已经安装了docker和docker-compose。 我可以看到图像,但我不知道如何启动它。
docker repo在hub.docker.com上。 我从那里拉了它。
我努力了:
docker run -d -p 5000:5000 grant/docker-app:hookedup
输出一些字符串: cdf4c4035e0...30b4d0881d635ecdac6f3
我也尝试过:
docker-compose build grant/docker-app:hookedup
哪个输出: Can't find a suitable configuration file in this directory or any
我也试过了
docker run --rm -p 3000:3000 grantspilsbury/docker-app:hookedup
它给出了输出:
> docker-sample-app@0.1.0 start /usr/src/app
> react-scripts start
Could not find a required file.
Name: index.html
Searched in: /usr/src/app/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! docker-sample-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
如果我运行docker ps或docker ps -a我得到:
[ec2-user@ip-172...-26 ~]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[ec2-user@ip-172...-26 ~]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0ca69ff467bc grant/docker-app:hookedup "npm start" 24 minutes ago Exited (1) 24 minutes ago happy_archimedes
2a01050f3bb6 grant/docker-app:hookedup "npm start" About an hour ago Exited (1) About an hour ago wonderful_rosalind
如果我运行docker logs 0ca69ff467bc,我会得到outpu:
Could not find a required file.
Name: index.html
Searched in: /usr/src/app/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! docker-sample-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the docker-sample-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-01-27T03_35_55_030Z-debug.log
容器内部存在nodejs问题。 跑
docker run -it --rm -p 3000:3000 --entrypoint sh grantspilsbury/docker-app:hookedup
检查容器内的内容,尤其是/usr/src/app/public
。 也许,与您的开发人员合作。
在我看来,你在容器中有一个nodejs react app。 在WORKDIR中,有package.json。 但是,无法找到index.html
表示并非所有文件都复制到图像中,或者应用程序正在错误的路径中搜索。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.