我有一个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
答案 0 :(得分:0)
容器内部存在nodejs问题。运行
/usr/src/app/public
检查容器内的物品,尤其是index.html
。也许,与您的开发人员合作。
在我看来,你在容器中有一个nodejs react app。在WORKDIR中,有package.json。但是,找不到class Login extends Component {
render() {
return (
<KeyboardAvoidingView behavior="padding" style={styles.container}>
<View style={styles.loginContainer}>
<Image resizeMode="contain" style={styles.logo} source={require('../../../src/assets/images/image.png')} />
</View>
<View style={styles.formContainer}>
<LoginForm />
</View>
</KeyboardAvoidingView>
);
}
}
表示并非所有文件都被复制到图像中,或者应用程序正在错误的路径中搜索。