-
Notifications
You must be signed in to change notification settings - Fork 18.9k
docker.service: Add multi-user.target to After= in unit file #41297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add multi-user.target to the After= list in docker.service so that multi-user.target does not wait for docker.service (and consequently wait for network-online.target). Signed-off-by: Isaiah Grace <[email protected]>
|
Makes sense (from your description). I was slightly confused if both While it's ok to merge this change here, note that the systemd unit file that's included in the packages is taken from this repository; https://github.com/docker/docker-ce-packaging/tree/master/systemd (we should probably bring those back in this repository, after reviewing the changes between them, but that's something still on my list 😅) Could you open a pull request there as well? |
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ping @tianon PTAL
|
Thanks for the review @thaJeztah! This is my first time doing this, so I'm a little unsure how it all goes down, but i'm exited to contribute. I'll go put in a pull request on the docker-ce-packaging repo. |
|
So far you're doing great (thanks!) 👍 Commit message has a DCO sign-off (which people often forget). One thing I noticed is that you opened this pull request from your own master branch; I recommend creating a branch for each pull request; branches are "cheap" when working with Git, and having your own "master" branch clean, and each "feature / PR" you're working on in its own branch can save you a lot of headaches. Separate branches allow you to "switch" between features/fixes you're working on; very useful if you have more pull requests open (and some of those take longer to be reviewed, or need more work). It also saves some headaches if you're asked to "rebase" and/or "squash" commits. We do have a contributors guide, but it was moved between repositories, and has gone outdated unfortunately; it might still have some useful tips though; https://github.com/moby/moby/tree/master/docs/contributing |
|
I'm a little hesitant here because I can imagine some users expecting Docker to start as soon as possible during boot (especially if they're running what they consider to be "system" service inside Docker), and this reorders that. If this is causing trouble, perhaps our inclusion of |
|
Looking at the output of $ sudo systemctl list-units --type target
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
bluetooth.target loaded active active Bluetooth
cryptsetup.target loaded active active Local Encrypted Volumes
getty.target loaded active active Login Prompts
graphical.target loaded active active Graphical Interface
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target loaded active active Local File Systems
machines.target loaded active active Containers
multi-user.target loaded active active Multi-User System
network-online.target loaded active active Network is Online
network.target loaded active active Network
paths.target loaded active active Paths
remote-fs-pre.target loaded active active Remote File Systems (Pre)
remote-fs.target loaded active active Remote File Systems
slices.target loaded active active Slices
sockets.target loaded active active Sockets
sound.target loaded active active Sound Card
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
time-sync.target loaded active active System Time Synchronized
timers.target loaded active active Timers
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
21 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'. |
|
@tianon good to go, or want more eyes on it? |
|
I think it's good to go -- it'd be great to get more eyes on it (especially those that know systemd deeper than I do), but it seems perfectly sane for now (and trivial for users to override themselves if it does turn out to be a problem, and then we'll get more data 😈). |
|
OK, let's get this in for the next (20.0x) release 👍 |
|
Thanks for reverting.
To test: Result: |
|
Before considering this change in the future - bear in mind that cloud-init typically occurs before multi-user.target, and this would ensure that docker interaction could not occur within userdata or runcmd blocks. |
After installing docker on Arch, and enabling the docker.service, I noticed that the time to boot my computer increased substantially. I traced this down to a dependency chain involving docker, and I believe that I have a solution that maintains the correct functionality of the docker.service unit file, while also preventing the hang when booting.
- What I did
I noticed on my Arch machine that the time to reach multi-user.target was delayed by several seconds because docker.service was waiting for a network connection. This was preventing the launch of the graphical environment until my Wi-Fi was connected, adding about six seconds to my boot.
I added the multi-user.target to the After list on the docker.service unit file in hopes that it would allow multi-user.target to complete before docker.service. This seemed to work, and I think that it would make a good contribution to the unit file. The docker.service still starts up at boot, but it no longer stalls the graphical environment.
- How I did it
I used systemd-analyse and systemctl to locate what was causing my slow boot problem. I found that because socker.service requires network-online.target and is wanted by multi-user.target, the critical chain of services for the graphical.target included waiting for NetworkManager-wait-online.service. This meant that my computer was waiting until after my wifi connection was established to show me a login screen. By adding multi-user.target to the After list on my unit file, this situation was avoided.
- How to verify it
Add multi-user.target to the After= list in docker.service so that multi-user.target does not wait for docker.service (and consequently wait for network-online.target).
- Description for the changelog
-- After=network-online.target docker.socket firewalld.service
++ After=network-online.target docker.socket firewalld.service multi-user.target