Docker on macOS: Getting Started | raywenderlich.com

In this Docker tutorial, you’ll learn Docker vocabulary and the commands for creating, inspecting and removing containers, networks and data volumes. You’ll learn how to run Docker containers in the background or foreground, and switch between the two; how to publish ports; how to connect a database app and a web app running in separate containers; and how to share directories between containers and your Mac and among containers.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/9159-docker-on-macos-getting-started

Hi Audrey,
Thanks for your awesome tutorials always. But on my MacBook I have an issue on the following code:

docker run --network emoji-net --name emojijournal -it -p 8090:8080 -v $PWD:/root/project -w /root/project emojijournal-run sh -c .build-ubuntu/release/EmojiJournalServer

It occurs the following error:

invalid reference format: repository name must be lowercase

So I googled little bit regarding on this and found the resolution.

docker run --network emoji-net --name emojijournal -it -p 8090:8080 -v “$(pwd):/root/project” -w /root/project emojijournal-run sh -c .build-ubuntu/release/EmojiJournalServer

Just letting you know^^
Thank you.

thanks @barty82! the message happens if some part of your path has a space or similar character. I usually make sure my folder is on the Desktop, but quote marks are more convenient :smile:

Hi Audrey,

Just wanted to add for the benefit of others that when you first try to run docker run hello-world it may fail even when the docker app is running. The first time I ran docker from the terminal I had to enter my username and password for the docker site using the following command

docker login

Also worth mentioning that you have to enter your username not your email address, even though it leads you to believe you have to enter your email.

After you have done it once on a Mac and it is stored in the keychain, you are good to go next time, no login is required again.

Great tutorial!

thanks @witham! although I did test without logging in, and it worked. More than one of my RW colleagues pointed out to me that you don’t need to login to pull, or even to search Docker Hub. I was trying to avoid readers having to even register, because there were some posts in the Docker forum, saying it took a long time to get the confirm-your-email email. That’s why I supplied the direct link to download Docker.

Glad you enjoyed the tutorial :]

Hey Audry!

Thanks for writing up this tutorial. Unfortunately, I’m hitting a roadblock. I run the command $ . runDocker.sh, the server is not started, instead I have this message on the last line “sh: 1: .build-ubuntu/release/EmojiJournalServer: not found”. I have removed all of the containers and images and gone back through the tutorial, to no avail. Same error.

Uploaded is a screenshot of the containers that are on my system, but when I type docker ps, only couchdb seems to be running.

46%20PM

Any ideas are appreciated!
Peter

hi Peter: when I run that command, the .build-ubuntu/release folder is created right near the end, just after this output:

Resolving GitHub - Kitura/CircuitBreaker: A Swift Circuit Breaker library – Improves application stability and reliability. at 5.0.1
Cloning GitHub - Kitura/Configuration: Hierarchical configuration manager for Swift applications
Resolving GitHub - Kitura/Configuration: Hierarchical configuration manager for Swift applications at 3.0.2

and just before this output:

[2019-03-22T06:38:30.703Z] [INFO] [Application.swift:63 connectionProperties] No cloud credentials. Running in Docker

Shift-Command-. in Finder shows the hidden files. See what you have?

Hey Audrey,

I am able to look into my .build-ubuntu folder. Inside, there are two directories (“checkouts” and “repositories”) and one text file “regenerate-token”. There is no directory /release inside :confused:

@audrey Can you please help with this when you get a chance? Thank you - much appreciated! :]

if you still have the Terminal window where you ran the command, scroll back to see if there was an error when it was cloning from IBM-Swift. Or run the command again, and see what’s happening?

Hi audrey,
Thanks for the tutorial, unfortantely When trying to build wift, My terminal window gets stuck on the stencil.GIt fetch command. Any reason for that ?38%20PM

Can you help please?

scrap all the earlier stuff below, and just download the EmojiJournalServer from David’s Kitura Stencil tutorial. localhost:8080 will only show Hello, world! but localhost:8080/client works.

ah, except David’s version uses an IBM-hosted DB, so it won’t use your local CouchDB Docker container, and all the rest of this tutorial won’t make sense 
 try replacing David’s Application.swift with the one in this tutorial. I have to go out now, but I’ll check back tonight.

hi! I poked around in the [GitHub repo's Package.swift](https://github.com/IBM-Swift/Kitura-StencilTemplateEngine/blob/master/Package.swift) and changed EmojiJournalServer's Package.swift's dependencies — the key for Stencil is Kitura-TemplateEngine.git (no Stencil anymore) at version 2.0.0. I updated a few other versions according to the Package.swift from the Docker Kitura sample. `swift build` is running, currently fetching TypeDecoder.git ... update to this: it seems to be stuck on this, but it's only a minor version update ... I'll let you know what happens.

Update 2: I changed Configuration.git to 3.0.2, but it’s still stuck on TypeDecoder. I’ve slack-messaged @dokun1 . Stay tuned.

I’ll check the rest of the tutorial, then update it to Xcode 4.2 etc.

import PackageDescription

let package = Package(
  name: "EmojiJournalServer",
  dependencies: [
    .package(url: "https://github.com/IBM-Swift/Kitura.git", .upToNextMinor(from: "2.6.0")),
    .package(url: "https://github.com/IBM-Swift/HeliumLogger.git", .upToNextMinor(from: "1.8.0")),
    .package(url: "https://github.com/IBM-Swift/Kitura-CouchDB.git", .upToNextMinor(from: "2.0.1")),
    .package(url: "https://github.com/IBM-Swift/Kitura-TemplateEngine.git", .upToNextMinor(from: "2.0.0")),
    .package(url: "https://github.com/IBM-Swift/CloudEnvironment.git", from: "9.0.0"),
    .package(url: "https://github.com/IBM-Swift/Configuration.git", from: "3.0.0"),
    .package(url: "https://github.com/RuntimeTools/SwiftMetrics.git", from: "2.0.0"),
    .package(url: "https://github.com/IBM-Swift/Health.git", from: "1.0.0"),
    ],
  targets: [
    .target(name: "EmojiJournalServer", dependencies: ["Configuration", "CloudEnvironment", "SwiftMetrics", "Health", "Kitura", "HeliumLogger", "CouchDB", "KituraStencil"])
  ]
)

Hi audrey,
Should I just wait till the tutorial is updated?

yes, that’s probably best 
 it’s not so straightforward, have to swap CouchDB in for Postgres to make David’s work here, probably easier to get my version working — I ran up against “SwiftyJSON not found” 
 back soon.

OK, I’ve updated the Download Materials — reload the page, and you should get https://koenig-media.raywenderlich.com/uploads/2018/11/EmojiJournalServer-1.zip — some of the Package.swift versions have been updated.

Let me know if it works for you?

1 Like

Hi audrey,
I got the new material and tried to go thru it,

I got this error when running . runDocker.sh

docker: Error response from daemon: pull access denied for on, repository does not exist or may require ‘docker login’.
See ‘docker run --help’.
Unable to find image ‘on:latest’ locally
docker: Error response from daemon: pull access denied for on, repository does not exist or may require ‘docker login’.
See ‘docker run --help’

I don’t understand why it’s looking for ‘on:latest’ — it should be using ‘emojijournal-build:latest’

I’ve attached the output that I get:

runDocker-output.txt.zip (3.8 KB)

Do a Find for tagged — there are two of these, for ‘emojijournal-run:latest’ and ‘emojijournal-build:latest’, which correspond to the first 2 docker build commands in runDocker.sh. Then the third command runs ‘emojijournal-build’.

Compare with your output? And check your runDocker.sh?

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!