Work locally on app that is inside CoreOS Docker container, running on Vagrant on Mac.

44 views
Skip to first unread message

Michael Chavez

unread,
Dec 31, 2016, 6:04:52 PM12/31/16
to CoreOS Dev
Hello CoreOS Dev Google Group,

I am a super noob. 

I got CoreOS running on my Macbook using Vagrant. I am able to get the Apache2 Ubuntu Default Page. What I want to do for example, is being able to modify/replace the file at /var/www/html/index.html. Later I want to use the technique to develop Node.js and WordPress apps locally and deploy to remote webservers, ala "Cloud Native" style.

I am able to have files shared from local directory on my Macbook to the CoreOS by adding/uncommenting this from the Vagrant file:
      config.vm.synced_folder ".", "/home/core/share", id: "core", :nfs => true, :mount_options => ['nolock,vers=3,udp']
That works in syncing the "share" folder inside CoreOS running inside of Vagrant to my local directory on Macbook, but I can't figure out how to get that to sync to the container inside of CoreOS running Ubuntu with Apache. 

I've been following these tutorials:
https://docs.docker.com/engine/tutorials/dockervolumes (this is where things don't work for me)

I am going about this the right way? Should I just use Docker for Mac and cut the CoreOS on Vagrant out (I don't want to necessarily do that)? 

Any help would be greatly appreciated!

Thanks and happy new years!

Cheers,
Michael

Rob Szumski

unread,
Jan 3, 2017, 12:40:51 PM1/3/17
to coreos-dev
Have you tried `docker run blah -v /home/core/share:/var/www/html/`? The second path is inside the container.

 - Rob

Michael Chavez

unread,
Jan 3, 2017, 4:25:23 PM1/3/17
to CoreOS Dev
Hello Rob,

Thanks for your reply.

I tried `docker run myusername/apache -v /home/core/share:/var/www/html/` and receive this error:
"exec: "-v": executable file not found in $PATH
docker: Error response from daemon: oci runtime error: exec: "-v": executable file not found in $PATH."

Any ideas what I am missing?

Cheers,
Michael

Rob Szumski

unread,
Jan 3, 2017, 4:28:06 PM1/3/17
to coreo...@googlegroups.com
Sorry, I was typing fast without being 100% accurate, you need the flags before the image name. So it needs to be `docker run -v /home/core/share:/var/www/html/ myusername/apache`

Michael Chavez

unread,
Jan 3, 2017, 5:18:08 PM1/3/17
to CoreOS Dev
Thanks again for your reply, I tried `docker run -v /home/core/share:/var/www/html/ myusername/apache` without getting errors, but doing `docker inspect NAME`, I see the mounts array is empty: "Mounts": []. Also, updating index.html in the shared folder doesn't update the default apache home page. 

Getting closer...

On Tuesday, January 3, 2017 at 9:40:51 AM UTC-8, Rob Szumski wrote:
Message has been deleted

Michael Chavez

unread,
Jan 3, 2017, 6:23:23 PM1/3/17
to CoreOS Dev
Here is the steps to recreate:
On MacBook Pro running macOS Sierra version 10.12.2.
Virtualbox:
5.1.12r112440
Vagrant:
Vagrant 1.9.1

`cd coreos-vagrant`

Comment out line 127 and 128 of the Vagrantfile and add:
config.vm.network "private_network", ip: "172.17.8.150"

Uncomment line 132 to enable NFS for sharing the host machine into the coreos-vagrant VM.

run:
'vagrant up'
ssh in:
'vagrant ssh'

Then run, from within the coreos shell:
`docker run -d -p 80:80 coreos/apache /usr/sbin/apache2ctl -D FOREGROUND`

Then go to: http://172.17.8.150/ in your browser. You'll see the text:
"It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet."

Then try to mount the volume the /home/core/share folder by running:
`docker run -v /home/core/share:/var/www coreos/apache`

I get error:
"docker: Error response from daemon: No command specified."

That is pretty much as far as I've made it. 
Message has been deleted

Rob Szumski

unread,
Jan 3, 2017, 7:09:27 PM1/3/17
to CoreOS User
Moving to the user list since this is more focused on using containers, rather than dev-ing on Container Linux.

Here’s an example of a full vagrant env that is similar to what you’re trying to do:

 I’d encourage you to read up on Docker volumes, this shouldn’t be to challenging to get working.

On Jan 3, 2017, at 3:25 PM, Michael Chavez <bigbas...@gmail.com> wrote:

Hi Rob,

I posted the steps to recreate using the CoreOS image of Apache. I am getting different error now using the cores/apache image: "docker: Error response from daemon: No command specified.". 

Cheers,
Michael

On Tuesday, January 3, 2017 at 9:40:51 AM UTC-8, Rob Szumski wrote:

Michael Chavez

unread,
Jan 3, 2017, 10:05:21 PM1/3/17
to CoreOS Dev
Yes! Finally got it to work.
`docker run -d -p 80:80 -v /home/core/share:/var/www/  coreos/apache /usr/sbin/apache2ctl -D FOREGROUND`

Thanks Rob for your extra set of eyes.

Cheers,
Michael


On Saturday, December 31, 2016 at 3:04:52 PM UTC-8, Michael Chavez wrote:
Reply all
Reply to author
Forward
0 new messages